feat: support case insensitive regex

pull/3/head
Trumeet 5 years ago
parent 0ad9808763
commit 821b11bcb5
No known key found for this signature in database
GPG Key ID: AE9E79B91CD492DD

@ -65,10 +65,10 @@ async function fetchHandler(e) {
}
// cfworker 会把路径中的 `//` 合并成 `/`
path = urlObj.href.substr(urlObj.origin.length + PREFIX.length).replace(/^https?:\/+/, 'https://')
const exp1 = /^(?:https?:\/\/)?github\.com\/.+?\/.+?\/(?:releases|archive)\/.*$/
const exp2 = /^(?:https?:\/\/)?github\.com\/.+?\/.+?\/(?:blob)\/.*$/
const exp3 = /^(?:https?:\/\/)?github\.com\/.+?\/.+?\/(?:info|git-upload-pack).*$/
const exp4 = /^(?:https?:\/\/)?raw\.githubusercontent\.com\/.+?\/.+?\/.+?\/.+$/
const exp1 = /^(?:https?:\/\/)?github\.com\/.+?\/.+?\/(?:releases|archive)\/.*$/i
const exp2 = /^(?:https?:\/\/)?github\.com\/.+?\/.+?\/(?:blob)\/.*$/i
const exp3 = /^(?:https?:\/\/)?github\.com\/.+?\/.+?\/(?:info|git-upload-pack).*$/i
const exp4 = /^(?:https?:\/\/)?raw\.githubusercontent\.com\/.+?\/.+?\/.+?\/.+$/i
if (path.search(exp1) === 0 || !Config.jsdelivr && path.search(exp2) === 0 || !Config.cnpmjs && (path.search(exp3) === 0 || path.search(exp4))) {
return httpHandler(req, path)
} else if (path.search(exp2) === 0) {

Loading…
Cancel
Save