mirror of https://github.com/hunshcn/gh-proxy
fix: raw.github.com在cnpmjs为1下的错误302
parent
4d655d09b7
commit
d978d13efb
|
@ -140,7 +140,8 @@ def proxy(u):
|
||||||
return redirect(u)
|
return redirect(u)
|
||||||
elif (jsdelivr or pass_by) and exp4.match(u):
|
elif (jsdelivr or pass_by) and exp4.match(u):
|
||||||
u = re.sub(r'(\.com/.*?/.+?)/(.+?/)', r'\1@\2', u, 1)
|
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)
|
return redirect(u)
|
||||||
else:
|
else:
|
||||||
if exp2.match(u):
|
if exp2.match(u):
|
||||||
|
|
2
index.js
2
index.js
|
@ -84,7 +84,7 @@ async function fetchHandler(e) {
|
||||||
const newUrl = path.replace(/^(?:https?:\/\/)?github\.com/, 'https://github.com.cnpmjs.org')
|
const newUrl = path.replace(/^(?:https?:\/\/)?github\.com/, 'https://github.com.cnpmjs.org')
|
||||||
return Response.redirect(newUrl, 302)
|
return Response.redirect(newUrl, 302)
|
||||||
} else if (path.search(exp4) === 0) {
|
} 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)
|
return Response.redirect(newUrl, 302)
|
||||||
} else {
|
} else {
|
||||||
return fetch(ASSET_URL + path)
|
return fetch(ASSET_URL + path)
|
||||||
|
|
Loading…
Reference in New Issue