@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.
Files changed (2) hide show
  1. package/dist/ui/html.js +2 -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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
2
- const jsonForScript = (value)=>JSON.stringify(value ?? {}).replace(/</g, '\\u003c');
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 = JSON.stringify(specUrl);
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seshuk/payload-plugin-openapi",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "OpenAPI 3.0/3.1/3.2 spec generator for Payload CMS, with Scalar/Swagger UI.",
5
5
  "keywords": [
6
6
  "api-docs",