Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/shared/src/markdownLinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ describe("inlineCodeFilePathCandidate", () => {
["/bin/echo hello world.txt", null],
["~/bin/run tests.sh", null],
["/Users/me/notes with spaces.md", "/Users/me/notes with spaces.md"],
["~/Videos/clips/<thread-slug>/shot.png", null],
["clips/<name>.mp4", null],
])("distinguishes file paths from code and hostnames in %s", (source, candidate) => {
expect(inlineCodeFilePathCandidate(source)).toBe(candidate);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/markdownLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function looksLikeHostname(segment: string, hasPosition: boolean): boolean {

export function inlineCodeFilePathCandidate(codeText: string): string | null {
const trimmed = codeText.trim();
if (trimmed.length === 0 || trimmed.includes("`")) return null;
if (trimmed.length === 0 || trimmed.includes("`") || /[<>]/.test(trimmed)) return null;
if (INLINE_CODE_WHITESPACE_PATTERN.test(trimmed) && !isSpacedAbsoluteFilePath(trimmed)) {
return null;
}
Expand Down
Loading