Merge remote-tracking branch 'origin/master'

# Conflicts:
#	README.md
#	index.js
pull/66/head
hunsh 2022-02-15 23:16:50 +08:00
commit 84cb44da1b
2 changed files with 6 additions and 5 deletions

View File

@ -48,9 +48,9 @@ github release、archive以及项目文件的加速项目支持clone有Clo
注册,登陆,`Start building`,取一个子域名,`Create a Worker`。
复制 [index.js](https://cdn.jsdelivr.net/hunshcn/gh-proxy@master/index.js) 到左侧代码框,`Save and deploy`。如果正常,右侧应显示首页。
复制 [index.js](https://cdn.jsdelivr.net/gh/hunshcn/gh-proxy@master/index.js) 到左侧代码框,`Save and deploy`。如果正常,右侧应显示首页。
`index.js`默认配置下项目文件会走jsDeliver如需走worker修改Config变量即可
`index.js`默认配置下项目文件会走jsDelivr如需走worker修改Config变量即可
`ASSET_URL`是静态资源的url实际上就是现在显示出来的那个输入框单页面
@ -81,7 +81,7 @@ docker run -d --name="gh-proxy-py" \
python版本的机器如果无法正常访问github.io会启动报错请自行修改静态文件url
workers版本默认配置下项目文件会走jsDeliver_如需走服务器_,修改配置即可
workers版本默认配置下项目文件会走jsDelivr如需走服务器修改配置即可
python版本默认走服务器2021.3.27更新)

View File

@ -27,6 +27,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
@ -59,7 +60,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
}
@ -80,7 +81,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 || (path.search(exp3) === 0 || path.search(exp4) === 0)) {
if (path.search(exp1) === 0 || path.search(exp5) === 0 || path.search(exp6) === 0 || path.search(exp3) === 0 || path.search(exp4) === 0) {
return httpHandler(req, path)
} else if (path.search(exp2) === 0) {
if (Config.jsdelivr) {