@seshuk/payload-plugin-openapi 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/html.js +2 -2
- package/package.json +1 -1
package/dist/ui/html.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const escapeHtml = (value)=>value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
2
|
-
const jsonForScript = (value)=>JSON.stringify(value ?? {}).replace(
|
|
2
|
+
const jsonForScript = (value)=>JSON.stringify(value ?? {}).replace(/[<>&\u2028\u2029]/g, (char)=>`\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`);
|
|
3
3
|
const htmlPage = ({ title, head, body })=>`<!doctype html><html><head><meta charset="utf-8"/><title>${escapeHtml(title)}</title><meta name="viewport" content="width=device-width, initial-scale=1"/>${head}</head><body>${body}</body></html>`;
|
|
4
4
|
const specUrlExpr = (specUrl)=>{
|
|
5
|
-
const u =
|
|
5
|
+
const u = jsonForScript(specUrl);
|
|
6
6
|
return `(function(){var l=new URLSearchParams(location.search).get('lang');return ${u}+(l?((${u}.indexOf('?')>-1?'&':'?')+'lang='+encodeURIComponent(l)):'')})()`;
|
|
7
7
|
};
|
|
8
8
|
export { escapeHtml, htmlPage, jsonForScript, specUrlExpr };
|