Skip to content

Commit 5de39b9

Browse files
committed
fix url valid
1 parent 54021e1 commit 5de39b9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/content-scripts/ufs_global.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ function runInBackground(fnPath, params) {
156156
}
157157
async function fetchByPassOrigin(url, options = {}) {
158158
try {
159-
let _url = url;
160-
let urlObject = new URL(url);
159+
let _url = makeUrlValid(url);
160+
let urlObject = new URL(_url);
161161
// https://stackoverflow.com/a/9375786/23648002
162162
if (location.hostname == urlObject?.hostname) {
163163
_url = urlObject.pathname;
@@ -925,6 +925,9 @@ function makeUrlValid(url) {
925925
if (url.startsWith("//")) {
926926
url = "https:" + url;
927927
}
928+
if (url.startsWith("/")) {
929+
url = location.origin + url;
930+
}
928931
return url;
929932
}
930933
function getWatchingVideoSrc() {
@@ -1299,6 +1302,7 @@ async function getLargestImageSrc(imgSrc, webUrl) {
12991302
}
13001303

13011304
// bypass redirect
1305+
imgSrc = makeUrlValid(imgSrc);
13021306
let redirectedUrl = await getRedirectedUrl(imgSrc);
13031307
if (redirectedUrl) {
13041308
imgSrc = redirectedUrl;

0 commit comments

Comments
 (0)