-
Notifications
You must be signed in to change notification settings - Fork 584
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove broken emoji from text (#1693)
* remove broken emoji from string * add changeset * add test * update changeset * delete old changeset * remove console.log
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@builder.io/mitosis': patch | ||
--- | ||
|
||
[Builder]: Remove broken emoji from text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { BuilderContent } from '@builder.io/sdk'; | ||
import { builderContentToMitosisComponent } from './builder'; | ||
|
||
describe('Unpaired Surrogates', () => { | ||
test('removes unpaired surrogates from Text component content', () => { | ||
const builderContent: BuilderContent = { | ||
data: { | ||
blocks: [ | ||
{ | ||
'@type': '@builder.io/sdk:Element' as const, | ||
component: { | ||
name: 'Text', | ||
options: { | ||
text: `Hello \uD800 World. Welcome to \uDFFF section`, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const output = builderContentToMitosisComponent(builderContent); | ||
// Text should be cleaned of unpaired surrogates | ||
expect(output.children[0].children[0].properties._text).toBe( | ||
'Hello World. Welcome to section', | ||
); | ||
// Verify unpaired surrogates are removed | ||
expect(output.children[0].children[0].properties._text).not.toContain('\uD800'); | ||
expect(output.children[0].children[0].properties._text).not.toContain('\uDFFF'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters