Repository navigation
fix(web): 带行号的网页链接不再当作工作区文件 - #496
Merged
Merged
Conversation
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.
parseProjectFileLink会拒绝未知协议,但保留了一个形如foo.ts:12的本地路径例外。这个例外没有限定协议部分,带行号的网页链接也会命中:https://example.com/report.md:12会被解析成工作区路径https://example.com/report.md(行 12)。ResourceLink随后按文件链接渲染——文件图标、#workspace-filehref、文件悬浮提示和文件右键菜单;只有点击时因为webURL优先才打开网页,交互前后不一致。修复把行号解析提前到协议判断之前,让
https:在去掉:12后仍能被识别为协议并拒绝;同时移除\.\w+:\d+这个会掩盖协议的例外。src/report.md:12和C:/project/report.md:12仍按文件路径解析,file:///的处理不变。回归用例:
https://example.com/report.md:12:旧实现返回{ path: "https://example.com/report.md", line: 12 },新实现返回nullmailto:user@example.com:12:不再被当作文件src/report.md:12与C:/project/report.md:12:保持原结果验证:
npx vitest run src/v2/components/resource-link.test.tsx:11/11 通过;新增用例在旧实现下失败npx vitest run:268 个文件、2608 个用例全部通过npm run typecheck:通过npm run build:通过边界:没有在真实浏览器里点击或悬浮该链接;本次只改解析结果,未改
ResourceLink的展示规则。以scheme:开头的顶层字符串(如a:b.md:12)现在按协议处理并拒绝;带目录部分的src/a:b.md:12仍按路径处理。