Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wuls committed Apr 15, 2024
1 parent 4de9a72 commit 5ef5ffc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/qwik/src/core/platform/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export const createPlatform = (): CorePlatform => {
*/
export const toUrl = (doc: Document, containerEl: QwikElement, url: string | URL): URL => {
const baseURI = new URL(doc.baseURI);
const base = containerEl?.getAttribute('q:base') ?? '/';
const pathUrl = (base + url).replace(/\/+/g, '/');
return new URL(pathUrl, baseURI.origin);
const base = new URL(containerEl.getAttribute('q:base') ?? baseURI, baseURI);
const pathUrl = (base.pathname + url).replace(/\/+/g, '/');
return new URL(pathUrl, base.origin);
};

let _platform = /*#__PURE__ */ createPlatform();
Expand Down
6 changes: 3 additions & 3 deletions packages/qwik/src/qwikloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ export const qwikLoader = (doc: Document, hasInitialized?: number) => {
if (attrValue) {
const container = element.closest('[q\\:container]')!;
const baseURI = new URL(doc.baseURI);
const base = container?.getAttribute('q:base') ?? '/';
const base = new URL(container.getAttribute('q:base') ?? baseURI, baseURI);
for (const qrl of attrValue.split('\n')) {
const pathUrl = (base + qrl).replace(/\/+/g, '/');
const url = new URL(pathUrl, baseURI.origin);
const pathUrl = (base.pathname + qrl).replace(/\/+/g, '/');
const url = new URL(pathUrl, base.origin);
const symbolName = url.hash[replace](/^#?([^?[|]*).*$/, '$1') || 'default';
const reqTime = performance.now();
let handler: any;
Expand Down
6 changes: 3 additions & 3 deletions packages/qwik/src/testing/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ export function setTestPlatform(_setPlatform: Function) {
*/
export function toUrl(doc: Document, containerEl: Element, url: string | URL): URL {
const baseURI = new URL(doc.baseURI);
const base = containerEl?.getAttribute('q:base') ?? '/';
const pathUrl = (base + url).replace(/\/+/g, '/');
return new URL(pathUrl, baseURI.origin);
const base = new URL(containerEl.getAttribute('q:base') ?? baseURI, baseURI);
const pathUrl = (base.pathname + url).replace(/\/+/g, '/');
return new URL(pathUrl, base.origin);
}

function toPath(url: URL) {
Expand Down

0 comments on commit 5ef5ffc

Please sign in to comment.