mirror of https://github.com/hunshcn/gh-proxy
commit
2bdb981754
5
index.js
5
index.js
|
@ -28,6 +28,7 @@ const exp2 = /^(?:https?:\/\/)?github\.com\/.+?\/.+?\/(?:blob|raw)\/.*$/i
|
|||
const exp3 = /^(?:https?:\/\/)?github\.com\/.+?\/.+?\/(?:info|git-).*$/i
|
||||
const exp4 = /^(?:https?:\/\/)?raw\.(?:githubusercontent|github)\.com\/.+?\/.+?\/.+?\/.+$/i
|
||||
const exp5 = /^(?:https?:\/\/)?gist\.(?:githubusercontent|github)\.com\/.+?\/.+?\/.+$/i
|
||||
const exp6 = /^(?:https?:\/\/)?github\.com\/.+?\/.+?\/tags.*$/i
|
||||
|
||||
/**
|
||||
* @param {any} body
|
||||
|
@ -60,7 +61,7 @@ addEventListener('fetch', e => {
|
|||
|
||||
|
||||
function checkUrl(u) {
|
||||
for (let i of [exp1, exp2, exp3, exp4, exp5, ]) {
|
||||
for (let i of [exp1, exp2, exp3, exp4, exp5, exp6 ]) {
|
||||
if (u.search(i) === 0) {
|
||||
return true
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ async function fetchHandler(e) {
|
|||
}
|
||||
// cfworker 会把路径中的 `//` 合并成 `/`
|
||||
path = urlObj.href.substr(urlObj.origin.length + PREFIX.length).replace(/^https?:\/+/, 'https://')
|
||||
if (path.search(exp1) === 0 || path.search(exp5) === 0 || !Config.cnpmjs && (path.search(exp3) === 0 || path.search(exp4) === 0)) {
|
||||
if (path.search(exp1) === 0 || path.search(exp5) === 0 || path.search(exp6) === 0 || !Config.cnpmjs && (path.search(exp3) === 0 || path.search(exp4) === 0)) {
|
||||
return httpHandler(req, path)
|
||||
} else if (path.search(exp2) === 0) {
|
||||
if (Config.jsdelivr) {
|
||||
|
|
Loading…
Reference in New Issue