Skip to content

Commit 2647bfb

Browse files
committed
Use anchor instead of URL for relative to absolute path convertion
Use an anchor element's href attribute to convert relative paths to absolute paths
1 parent 2fbc2f8 commit 2647bfb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/runtime/internal/utils.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,16 @@ export function safe_not_equal(a, b) {
4040
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
4141
}
4242

43-
export function src_url_equal(a, b) {
44-
return new URL(a, window.location.origin).href === (new URL(b, window.location.origin)).href;
43+
const relative_to_absolute = (function() {
44+
const anchor = document.createElement('a');
45+
return function(url) {
46+
anchor.href = url;
47+
return anchor.href;
48+
};
49+
})();
50+
51+
export function src_url_equal(element_src, url) {
52+
return element_src === relative_to_absolute(url);
4553
}
4654

4755
export function not_equal(a, b) {

0 commit comments

Comments
 (0)