mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat(driver): add option to strip out lone surrogates (#29179)
https://github.com/microsoft/playwright-dotnet/issues/2819
This commit is contained in:
parent
f4b8ff9c95
commit
4df4054f19
@ -38,7 +38,15 @@ export function runDriver() {
|
||||
});
|
||||
const transport = new PipeTransport(process.stdout, process.stdin);
|
||||
transport.onmessage = (message: string) => dispatcherConnection.dispatch(JSON.parse(message));
|
||||
dispatcherConnection.onmessage = message => transport.send(JSON.stringify(message));
|
||||
// Certain Language Binding JSON parsers (e.g. .NET) do not like strings with lone surrogates.
|
||||
const isJavaScriptLanguageBinding = !process.env.PW_LANG_NAME || process.env.PW_LANG_NAME === 'javascript';
|
||||
const replacer = !isJavaScriptLanguageBinding && (String.prototype as any).toWellFormed ? (key: string, value: any): any => {
|
||||
if (typeof value === 'string')
|
||||
// @ts-expect-error
|
||||
return value.toWellFormed();
|
||||
return value;
|
||||
} : undefined;
|
||||
dispatcherConnection.onmessage = message => transport.send(JSON.stringify(message, replacer));
|
||||
transport.onclose = () => {
|
||||
// Drop any messages during shutdown on the floor.
|
||||
dispatcherConnection.onmessage = () => {};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user