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
pull/6449/head
Altan Birler 5 years ago
parent 2fbc2f8741
commit 2647bfbbee

@ -40,8 +40,16 @@ export function safe_not_equal(a, b) {
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}
export function src_url_equal(a, b) {
return new URL(a, window.location.origin).href === (new URL(b, window.location.origin)).href;
const relative_to_absolute = (function() {
const anchor = document.createElement('a');
return function(url) {
anchor.href = url;
return anchor.href;
};
})();
export function src_url_equal(element_src, url) {
return element_src === relative_to_absolute(url);
}
export function not_equal(a, b) {

Loading…
Cancel
Save