diff --git a/app/main.py b/app/main.py index 502ae97..f614982 100644 --- a/app/main.py +++ b/app/main.py @@ -140,7 +140,8 @@ def proxy(u): return redirect(u) elif (jsdelivr or pass_by) and exp4.match(u): u = re.sub(r'(\.com/.*?/.+?)/(.+?/)', r'\1@\2', u, 1) - u = u.replace('raw.githubusercontent.com', 'cdn.jsdelivr.net/gh', 1) + _u = u.replace('raw.githubusercontent.com', 'cdn.jsdelivr.net/gh', 1) + u = u.replace('raw.github.com', 'cdn.jsdelivr.net/gh', 1) if _u == u else _u return redirect(u) else: if exp2.match(u): diff --git a/index.js b/index.js index bb5d711..cad96de 100644 --- a/index.js +++ b/index.js @@ -84,7 +84,7 @@ async function fetchHandler(e) { const newUrl = path.replace(/^(?:https?:\/\/)?github\.com/, 'https://github.com.cnpmjs.org') return Response.redirect(newUrl, 302) } else if (path.search(exp4) === 0) { - const newUrl = path.replace(/(?<=com\/.+?\/.+?)\/(.+?\/)/, '@$1').replace(/^(?:https?:\/\/)?raw\.githubusercontent\.com/, 'https://cdn.jsdelivr.net/gh') + const newUrl = path.replace(/(?<=com\/.+?\/.+?)\/(.+?\/)/, '@$1').replace(/^(?:https?:\/\/)?raw\.(?:githubusercontent|github)\.com/, 'https://cdn.jsdelivr.net/gh') return Response.redirect(newUrl, 302) } else { return fetch(ASSET_URL + path)