Parse /.../ JavaScript/TypeScript regex syntax correctly.
rvantonder opened this issue · 0 comments
rvantonder commented
Fix issue where regular expression syntax /.../
isn't parsed to escape it's contents. When the contents affect (unbalanced parens or quotes), the file won't be parsed correctly. Buggy example:
async function handleRoot(req: http.IncomingMessage, resp: http.ServerResponse, entryPointPath: string, environmentService: INativeEnvironmentService) {
if (!req.headers.host) {
return serveError(req, resp, 400, 'Bad request.');
}
const workbenchConfig = {
developmentOptions: {
enableSmokeTestDriver: environmentService.driverHandle === 'web' ? true : undefined
}
};
const escapeQuote = (str: string) => str.replace(/"/g, '"');
const entryPointContent = (await fs.promises.readFile(entryPointPath))
.toString()
.replace('{{WORKBENCH_WEB_CONFIGURATION}}', escapeQuote(JSON.stringify(workbenchConfig)));
resp.writeHead(200, {
'Content-Type': 'text/html'
});
return resp.end(entryPointContent);
}
function main(...)
and comby 'main(...)' '' -match-only
returns no results