mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 18:05:45 +00:00
fix(javascript): resolve query-only HTML references to their document
This commit is contained in:
1 parent
08daf056cc
commit
55a46f7c71
3 files changed
+144
-5
No files matched your search
@@ -33,6 +33,28 @@ const resolve = (declaredPath: string, htmlBaseHref: string) =>
|
||||
});
|
||||
const documentUrl = "https://artifact.test/renderer/index.html";
|
||||
describe("HTML base href URL components", () => {
|
||||
it.each(["?base=1", "#base-fragment"])(
|
||||
"keeps the document pathname for suffix-only base href %s",
|
||||
(base) => {
|
||||
const resolvedBase = new URL(base, documentUrl);
|
||||
expect(new URL("app.js", resolvedBase).pathname).toBe("/renderer/app.js");
|
||||
expect(resolve("app.js", base)).toMatchObject({
|
||||
resolved_path: "renderer/app.js",
|
||||
resolution_status: "resolved",
|
||||
});
|
||||
|
||||
const emptyPathReference = "?script=1#fragment";
|
||||
expect(new URL(emptyPathReference, resolvedBase).pathname).toBe(
|
||||
"/renderer/index.html",
|
||||
);
|
||||
expect(resolve(emptyPathReference, base)).toMatchObject({
|
||||
declared_path: emptyPathReference,
|
||||
resolved_path: "renderer/index.html",
|
||||
resolution_status: "resolved",
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
"/assets/?cache=/wrong/",
|
||||
"/assets/#/wrong/",
|
||||
|
||||
Reference in new issue
Block a user