| author | |
| committer | |
| log | 88fbc2cac77ff2bf0d406c44754ecd8014976f5f |
| tree | fab4eb2417eb238c5b075f6ef714c62a850f7da4 |
| parent | 60cb7d180d9ebdd1010460ccd94cdfad1ec83042 |
| signature | Signed by PGP key B5690EEEBB952194 |
2 files changed, 13 insertions(+), 0 deletions(-)
packages/client-runtime/src/markdownLinks.test.ts+9| ... | ... | @@ -22,6 +22,15 @@ describe("inlineCodeFilePathCandidate", () => { |
| 22 | 22 | ["127.0.0.1:3000", null], |
| 23 | 23 | ["example.com/index.html", null], |
| 24 | 24 | ["example.pl/index.html", null], |
| 25 | ["z-ai/glm-5.3", null], | |
| 26 | ["z-ai/glm-5.3:12", null], | |
| 27 | ["python/3.12", null], | |
| 28 | ["Qwen/Qwen2.5-Coder", null], | |
| 29 | ["meta-llama/Llama-3.1-8B", null], | |
| 30 | ["share/man/ls.1", "share/man/ls.1"], | |
| 31 | ["usr/lib/libfoo.so.1", "usr/lib/libfoo.so.1"], | |
| 32 | ["vendor/jquery-3.6.0.min.js", "vendor/jquery-3.6.0.min.js"], | |
| 33 | ["./models/glm-5.3", "./models/glm-5.3"], | |
| 25 | 34 | ])("distinguishes file paths from code and hostnames in %s", (source, candidate) => { |
| 26 | 35 | expect(inlineCodeFilePathCandidate(source)).toBe(candidate); |
| 27 | 36 | }); |
packages/client-runtime/src/markdownLinks.ts+4| ... | ... | @@ -14,6 +14,9 @@ const POSITION_ONLY_PATTERN = /^\d+(?::\d+)?$/; |
| 14 | 14 | const INLINE_CODE_DISQUALIFIER_PATTERN = /[\s`]/; |
| 15 | 15 | const PATH_SEPARATOR_PATTERN = /[\\/]/; |
| 16 | 16 | const FILE_EXTENSION_PATTERN = /\.[A-Za-z0-9_-]+$/; |
| 17 | // A final dot between digits marks a version or model id (`glm-5.3`, | |
| 18 | // `Qwen2.5-Coder`), not an extension. `ls.1` and `libfoo.so.1` stay files. | |
| 19 | const VERSION_SUFFIX_PATTERN = /\d\.\d[^.]*$/; | |
| 17 | 20 | const NUMERIC_DOTTED_PATTERN = /^\d+(?:\.\d+)+$/; |
| 18 | 21 | // Standard OS and dev-container roots; deliberately excludes app-route-ish |
| 19 | 22 | // prefixes like /app/ or /chat/ so SPA routes never read as files. |
| ... | ... | @@ -176,6 +179,7 @@ export function inlineCodeFilePathCandidate(codeText: string): string | null { |
| 176 | 179 | .replace(/[/\\]+$/, "") |
| 177 | 180 | .split(/[\\/]/) |
| 178 | 181 | .at(-1) ?? ""; |
| 182 | if (VERSION_SUFFIX_PATTERN.test(basename)) return null; | |
| 179 | 183 | if (!hasPosition && !FILE_EXTENSION_PATTERN.test(basename)) return null; |
| 180 | 184 | } |
| 181 | 185 | return candidate; |