diff --git a/src/LibraryLoader.ts b/src/LibraryLoader.ts index 3d09f64..3d51058 100644 --- a/src/LibraryLoader.ts +++ b/src/LibraryLoader.ts @@ -10,7 +10,8 @@ export interface ILibraryDefinition { } export class LibraryLoader { - readonly cache = new Map(); + private readonly cache = new Map(); + readonly pathToUrl = new Map(); baseURL?: string; @@ -54,6 +55,7 @@ export class LibraryLoader { const url = new URL(path, githubURLToRaw(this.baseURL)); const result = await fetch(url); if (result.ok) { + this.pathToUrl.set(path, url.toString()); return result; } } diff --git a/src/index.ts b/src/index.ts index 5a7939a..a351259 100644 --- a/src/index.ts +++ b/src/index.ts @@ -88,7 +88,7 @@ renderer.onComponentClick.listen(async (path) => { } const newParams = new URLSearchParams(window.location.search); - newParams.set('file', path); + newParams.set('file', libraryLoader.pathToUrl.get(path) ?? path); history.pushState({ path }, '', '?' + newParams.toString()); await render(path); });