feat: support github.com/x/x/tags

pull/51/head
fcying 2022-01-21 09:32:47 +08:00
parent ff0d23567b
commit 677a5f6259
1 changed files with 3 additions and 2 deletions

View File

@ -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) {