EPUB: ignore query strings when resolving URLs

This commit is contained in:
John Factotum
2023-10-11 01:49:20 +08:00
parent 96d51e654a
commit d44e8d6d64
+3 -1
View File
@@ -64,7 +64,9 @@ const resolveURL = (url, relativeTo) => {
if (relativeTo.includes(':')) return new URL(url, relativeTo)
// the base needs to be a valid URL, so set a base URL and then remove it
const root = 'https://invalid.invalid/'
return decodeURI(new URL(url, root + relativeTo).href.replace(root, ''))
const obj = new URL(url, root + relativeTo)
obj.search = ''
return decodeURI(obj.href.replace(root, ''))
} catch(e) {
console.warn(e)
return url