Skip to content

Comments

修正 prettyUrl 不完整#1244

Merged
CodFrm merged 5 commits intoscriptscat:release/v1.3from
cyfung1031:pr-prettyUrl-004
Feb 15, 2026
Merged

修正 prettyUrl 不完整#1244
CodFrm merged 5 commits intoscriptscat:release/v1.3from
cyfung1031:pr-prettyUrl-004

Conversation

@cyfung1031
Copy link
Collaborator

自己写的 prettyUrl 要自己维护

我还是接受不了只是用一个小小的工具就要引入 整个 "punycode" package
"punycode" 没有 typescript 支持, 又不是 ESM

这些工具都放在 @App/pkg/utils/
有unit test 就行,日后也不用改什么

实际打包后有 rspack + ES2020 / ES2022,体积和语法都是最优化

@CodFrm
Copy link
Member

CodFrm commented Feb 14, 2026

哎呀,我只是喜欢有现成的库尽量用现成的,不自己维护,不过也确实只是需要decode功能,引入了一堆其它的

你弄了,那就用你的吧

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

这个PR将prettyUrl函数从utils.ts重构到专用的url-utils.ts文件,并实现了自定义的Punycode解码器,避免引入体积较大且缺乏TypeScript和ESM支持的punycode包。新实现提供了更完整的URL美化功能,包括Punycode域名解码、路径和查询参数的智能解码、以及对特殊字符的正确处理。

Changes:

  • 实现了符合RFC 3492标准的Punycode解码器
  • 重写了prettyUrl函数,增强了对国际化域名、路径、查询参数和hash的解码能力
  • 添加了全面的单元测试,覆盖各种边缘情况和国际化场景

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/pkg/utils/utils.ts 移除旧的prettyUrl实现
src/pkg/utils/url-utils.ts 新的prettyUrl实现,支持完整的URL解码和美化
src/pkg/utils/url-utils.test.ts prettyUrl的全面测试用例,包括256个测试场景
src/pkg/utils/punycode.ts 自定义的Punycode解码器实现
src/pkg/utils/punycode.test.ts Punycode解码器的测试用例
src/pages/install/App.tsx 更新导入路径,从新位置导入prettyUrl

@cyfung1031 cyfung1031 mentioned this pull request Feb 14, 2026
@cyfung1031 cyfung1031 added the P2 🐌 非重要也不紧急的内容 label Feb 15, 2026
@CodFrm CodFrm merged commit 511a986 into scriptscat:release/v1.3 Feb 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 🐌 非重要也不紧急的内容

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants