diff --git a/src/server/plugin/PatchHtml.ts b/src/server/plugin/PatchHtml.ts index 93e2351..fc21434 100644 --- a/src/server/plugin/PatchHtml.ts +++ b/src/server/plugin/PatchHtml.ts @@ -34,7 +34,10 @@ export class PatchHtml implements IPluginMiddleware { private insertTags = (req: Request, html: string | Buffer): string => { html = String(html) - if (!html.includes("__VERDACCIO_BASENAME_UI_OPTIONS")) { + if ( + !html.includes("__VERDACCIO_BASENAME_UI_OPTIONS") && + !html.includes("ui-options.js") + ) { return html } diff --git a/test/server/plugin/PatchHtml/insertTags.test.ts b/test/server/plugin/PatchHtml/insertTags.test.ts new file mode 100644 index 0000000..7769307 --- /dev/null +++ b/test/server/plugin/PatchHtml/insertTags.test.ts @@ -0,0 +1,51 @@ +import { describe, expect, it } from "vitest" +import { PatchHtml } from "src/server/plugin/PatchHtml" + +const scriptPattern = /verdaccio-6\.js/ + +function createPatchHtml() { + const config = { url_prefix: "" } as any + return new PatchHtml(config) +} + +function callInsertTags(html: string) { + const patchHtml = createPatchHtml() + const req = { headers: { host: "localhost:4873" }, protocol: "http" } as any + // Access the private method via bracket notation + return (patchHtml as any).insertTags(req, html) +} + +// Verdaccio <=6.4 inlines the options in a +