Skip to content

Commit dffe28d

Browse files
authored
Update qwikloader.ts
1 parent f8376b0 commit dffe28d

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

packages/qwik/src/qwikloader.ts

+8-12
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,17 @@ export const qwikLoader = (
9595
const attrValue = element[getAttribute](attrName);
9696
if (attrValue) {
9797
const container = element.closest('[q\\:container]')! as QContainerElement;
98-
const baseURI = new URL(doc.baseURI);
99-
const qBase = container[getAttribute]('q:base')!;
10098
const qVersion = container[getAttribute]('q:version') || 'unknown';
10199
const qManifest = container[getAttribute]('q:manifest-hash') || 'dev';
102-
const base = new URL(qBase ?? baseURI, baseURI);
100+
const base = container[getAttribute]('q:base');
101+
let base = qBase;
102+
if (!base || base === '/') {
103+
base = doc.baseURI;
104+
} else {
105+
base = base.endsWith('/') ? base : base + '/';
106+
}
103107
for (const qrl of attrValue.split('\n')) {
104-
const isStartSlash = qrl.toString().startsWith('/');
105-
const isEndslash = base.pathname.endsWith('/');
106-
const pathUrl =
107-
(isEndslash && !isStartSlash
108-
? base.pathname
109-
: isEndslash
110-
? base.pathname.slice(0, -1)
111-
: base.pathname) + qrl;
112-
const url = new URL(pathUrl, !base.origin ? base : base.origin);
108+
const url = new URL(qrl, base);
113109
const href = url.href;
114110
const symbol = url.hash[replace](/^#?([^?[|]*).*$/, '$1') || 'default';
115111
const reqTime = performance.now();

0 commit comments

Comments
 (0)