Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.replace(/(content\s*:\s*)(['"])([^'"]*)(['"])/g, function (
match,
pre,
quote,
innerContent,
quote2
) {
if (quote !== quote2) {
return
}
return pre + quote + jsesc(innerContent) + quote
})
// .. however it's not perfect for our needs,
export function StringLiteral(node: Object) {
const raw = this.getPossibleRaw(node);
if (!this.format.minified && raw != null) {
this.token(raw);
return;
}
// ensure the output is ASCII-safe
const opts = this.format.jsescOption;
if (this.format.jsonCompatibleStrings) {
opts.json = true;
}
const val = jsesc(node.value, opts);
return this.token(val);
}
check.it("parse a string", [gen.asciiString], (s) => {
const qs = `"${jsesc(s, {quotes: "double"})}"`;
const r = p.parse(p.quotedString, p.stream(qs));
assert(p.isResult(r), `parser output is not ParseResult, s '${s}' qs '${qs}'`);
assert.equal(r.value, s, `'${r.value}' did not match '${s}' - string was '${qs}'`);
});
});
export function wrapTextModule(id: string, source: string) {
const [before, after] = `define('${id}', function() {
return 'SPLIT';
});`.split('SPLIT');
const escaped = jsesc(source);
const str = new MagicString(source);
const startPiece = escaped.slice(0, source.length);
return str
.overwrite(0, source.length, startPiece)
.append(escaped.slice(source.length))
.append(after)
.prepend(before);
}
}
button[disabled] {
cursor: default;
}
#root {
height: 100vh;
}
`,
}}
/>
const stringify = object =>
`"${jsesc(JSON.stringify(object).replace(/
const generateRouteInformation = embeddedRouteInfo => ({
__html: `
window.__routeInfo = JSON.parse(${jsesc(JSON.stringify(embeddedRouteInfo), {
isScriptContext: true,
wrap: true,
json: true,
})});`,
})
constructor(public type: string, name: string | undefined, _value: any, public options: Options) {
const value = String(_value);
this.name = name || enumName(value, options);
if (type === 'string') {
this.value = `'${jsesc(value)}'`;
} else {
this.value = value;
}
}
}
function stringifySafely(obj) {
return jsesc(JSON.stringify(obj), {
json: true,
isScriptContext: true
});
}
/*
const createFile = (withAnnotation = false) => (script: string) => `export const createHTML = ${
withAnnotation ? '(html: string)' : 'html'
} => \`
<title>This is the webview</title>
<div id="${REMIRROR_ID}">\${html}</div>
\`;
`;