From c0446055aa1d5d13a1ed0ffcb0bcf377ebde4d72 Mon Sep 17 00:00:00 2001 From: Mankin <16741164+M4nk1n@users.noreply.github.com> Date: Mon, 18 Mar 2024 17:00:03 +0800 Subject: [PATCH 1/2] Update index.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 兼容 raw/gist 链接添加 https 前缀 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index f28106e..ef8f308 100644 --- a/index.js +++ b/index.js @@ -129,7 +129,7 @@ function httpHandler(req, pathname) { if (!flag) { return new Response("blocked", {status: 403}) } - if (urlStr.startsWith('github')) { + if (urlStr.startsWith('github') || urlStr.startsWith('raw.github') || urlStr.startsWith('gist.github')) { urlStr = 'https://' + urlStr } const urlObj = newUrl(urlStr) From 24f4bf2719976252a615bb6110c89f4928d13802 Mon Sep 17 00:00:00 2001 From: Mankin <16741164+M4nk1n@users.noreply.github.com> Date: Mon, 18 Mar 2024 17:25:29 +0800 Subject: [PATCH 2/2] Update index.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 判断 github 链接不为 http(s):// 开头时添加 https:// 前缀 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index ef8f308..dc71533 100644 --- a/index.js +++ b/index.js @@ -129,7 +129,7 @@ function httpHandler(req, pathname) { if (!flag) { return new Response("blocked", {status: 403}) } - if (urlStr.startsWith('github') || urlStr.startsWith('raw.github') || urlStr.startsWith('gist.github')) { + if (urlStr.search(/^https?:\/\//) !== 0) { urlStr = 'https://' + urlStr } const urlObj = newUrl(urlStr)