Merged
Conversation
Member
|
哎呀,我只是喜欢有现成的库尽量用现成的,不自己维护,不过也确实只是需要decode功能,引入了一堆其它的 你弄了,那就用你的吧 |
Contributor
There was a problem hiding this comment.
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 |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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.
自己写的 prettyUrl 要自己维护
我还是接受不了只是用一个小小的工具就要引入 整个 "punycode" package
"punycode" 没有 typescript 支持, 又不是 ESM
这些工具都放在
@App/pkg/utils/有unit test 就行,日后也不用改什么
实际打包后有 rspack + ES2020 / ES2022,体积和语法都是最优化