diff options
Diffstat (limited to 'tools/wpt')
| -rw-r--r-- | tools/wpt/utils.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/wpt/utils.ts b/tools/wpt/utils.ts index 13c68ec90..1f76ff128 100644 --- a/tools/wpt/utils.ts +++ b/tools/wpt/utils.ts @@ -154,6 +154,16 @@ export async function cargoBuild() { assert(status.success, "cargo build failed"); } +export function escapeLoneSurrogates(input: string): string; +export function escapeLoneSurrogates(input: string | null): string | null; +export function escapeLoneSurrogates(input: string | null): string | null { + if (input === null) return null; + return input.replace( + /[\uD800-\uDFFF]/gu, + (match) => `U+${match.charCodeAt(0).toString(16)}`, + ); +} + /// WPTREPORT export async function generateRunInfo(): Promise<unknown> { |
