Skip to content

Commit

Permalink
fix: qwikloader should not create URLs with double //
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Jun 22, 2021
1 parent 1c13e17 commit 289e877
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/qwikloader.ts
Expand Up @@ -44,11 +44,18 @@
const eventUrl = element.getAttribute('on:' + ev.type);
if (eventUrl) {
const url = new URL(
eventUrl.replace(/^(\w+):/, (str, protocol) => {
eventUrl.replace(/^(\w+):(\/)/, (str, protocol, slash) => {
const linkElm = doc.querySelector(
`link[rel="q.protocol.${protocol}"]`
) as HTMLLinkElement;
return (linkElm && linkElm.href) || str;
const href = linkElm && linkElm.href;
if (!href) {
throw new Error('QWIKLOADER-ERROR: `' + protocol + '` is not defined.');
}
if (slash && href.endsWith('/')) {
slash = '';
}
return href + slash;
})
);
const importPath = url.pathname + '.js';
Expand Down

0 comments on commit 289e877

Please sign in to comment.