summaryrefslogtreecommitdiff
path: root/tools/wpt/utils.ts
diff options
context:
space:
mode:
authorAndreu Botella <abb@randomunok.com>2021-07-07 19:56:47 +0200
committerGitHub <noreply@github.com>2021-07-07 19:56:47 +0200
commitc972fe6cec8f643fbafd0fe33b461798faedaf80 (patch)
tree394808f66b3b31e9956e0431121f0470c4966c7c /tools/wpt/utils.ts
parent29b9c89312547661fa8e32efd2f29a653b83d730 (diff)
tests: escape lone surrogates in wptreport (#11310)
Diffstat (limited to 'tools/wpt/utils.ts')
-rw-r--r--tools/wpt/utils.ts10
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> {