fix require() with root urls in /dir/page.html

This commit is contained in:
tophf 2022-01-13 14:00:52 +03:00
parent 549c0ba2c9
commit 365b706320

View File

@ -86,7 +86,7 @@
const tag = isCss ? 'link' : 'script';
const attr = isCss ? 'href' : 'src';
if (!isCss && !url.endsWith('.js')) url += '.js';
if (url.startsWith('/')) url = url.slice(1);
if (url[0] === '/' && location.pathname.indexOf('/', 1) < 0) url = url.slice(1);
let el = document.head.querySelector(`${tag}[${attr}$="${url}"]`);
if (!el) {
el = document.createElement(tag);