(待定)通用处理修正 - 引入 toEncodedUrl 避免 URL 错误解析问题 、修正 prettyUrl 不完整#1236
Draft
cyfung1031 wants to merge 3 commits intoscriptscat:release/v1.3from
Draft
(待定)通用处理修正 - 引入 toEncodedUrl 避免 URL 错误解析问题 、修正 prettyUrl 不完整#1236cyfung1031 wants to merge 3 commits intoscriptscat:release/v1.3from
cyfung1031 wants to merge 3 commits intoscriptscat:release/v1.3from
Conversation
Collaborator
Author
|
要調一下UI |
Member
|
fetch时应该用原本的url参数去处理,可读性的url简单处理即可 这又一大堆的代码,还专门特殊处理,看得头疼 |
Collaborator
Author
... 一大堆代码是之前写的prettyUrl 不太好 我注释都写得很清楚 唉 你自己搞。我不理了 |
Member
|
看得头大,每次修bug,结果变成大改动了,代码也看不下去 |
Collaborator
Author
|
我把 prettyUrl 拆出來 |
3c81653 to
cfff79f
Compare
(cherry picked from commit ec65ce1)
cyfung1031
commented
Feb 13, 2026
| try { | ||
| // 截取 "xn--" 前缀后进行解码 | ||
| const punycodePart = s.slice(4); | ||
| return punycodeDecode(punycodePart); |
Collaborator
Author
There was a problem hiding this comment.
虽然我已经不会在这 BUG FIX PR 搞prettyUrl.
但原本 72 行就搞定的东西,你偏要引用一个 压缩了也有 3KB 的老东西
Member
|
Case 1 本来就是一个不正确的url(使用curl判断),没必要还做特殊处理 |
Collaborator
Author
Member
2302906 to
fc7b701
Compare
Collaborator
Author
|
我开了一个 #1238 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

修复安装链接解析失败(关联 #1235)并优化 prettyUrl
本 PR 重点解决从 GreasyFork、SleazyFork 及自定义来源获取的安装链接在不同编码场景下解析失败、乱码、403 或 Punycode 显示异常的问题,同时完善 URL 规范化与安装页体验。
一、核心问题
encodeURI/encodeURIComponent&url=参数被浏览器或扩展多层编码,导致解析错位prettyUrl实现不完整,异常 URL 处理不足二、核心改动
1️⃣ DeclarativeNetRequest 重定向锚点机制(关键修复)
在
service_worker/script.ts新增精确 redirect 规则:regexSubstitution<,\1,>标记原始捕获 URL?url=<,\1,>目的:
&url=参数被错误拆分或二次解码2️⃣ 新增健壮 URL 工具(url-utils.ts)
新增
url-utils.ts+ 完整 Vitest 覆盖测试。✅
toEncodedURL(input: string)基于
new URL()做输入清洗与校验host 强制 Punycode 编码(支持 CJK / emoji / IDN)
分离编码 path / search / hash,避免双重编码
修复常见异常:
%编码✅
prettyUrl(url, base?)decodeURI安全解码路径URLSearchParams重建查询字符串&/=语义示例:
✅ 测试覆盖
3️⃣ 安装页国际化与体验优化
优化:
三、整体效果
Close #1235
keywords: Download Progress, Fetch, Script Installation Links, Encoding, Punycode, RFC 3492, regexSubstitution, chrome.declarativeNetRequest.Rule
Testing
https://update.greasyfork.org/scripts/550295/100%25%E8%A7%A3%E9%94%81CSDN%E6%96%87%E5%BA%93vip%E6%96%87%E7%AB%A0%E9%98%85%E8%AF%BB%E9%99%90%E5%88%B6.user.js
https://scriptcat.org/scripts/code/4939/%F0%9F%97%A8%EF%B8%8F%E6%B6%88%E6%81%AF%E5%AE%9A%E6%97%B6%E6%8E%A8%E9%80%81+%E2%80%94+%E8%84%9A%E6%9C%AC%E7%8C%AB.user.js
Case 1
Case 2