From 365b7063202d50b64976bc2e22938c007a86a39e Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 13 Jan 2022 14:00:52 +0300 Subject: [PATCH] fix require() with root urls in /dir/page.html --- js/polyfill.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/polyfill.js b/js/polyfill.js index d227ae21..908607bd 100644 --- a/js/polyfill.js +++ b/js/polyfill.js @@ -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);