Skip to content

Commit 12da503

Browse files
committed
Fixed path leading character handling to preserve language characters and remove specific punctuation marks
1 parent 3c75b81 commit 12da503

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

webview-ui/src/components/common/CodeAccordian.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ interface CodeAccordianProps {
1717
}
1818

1919
/*
20-
We need to remove leading non-alphanumeric characters from the path in order for our leading ellipses trick to work.
21-
^: Anchors the match to the start of the string.
22-
[^a-zA-Z0-9]+: Matches one or more characters that are not alphanumeric.
23-
The replace method removes these matched characters, effectively trimming the string up to the first alphanumeric character.
20+
We need to remove certain leading characters from the path in order for our leading ellipses trick to work.
21+
However, we want to preserve all language characters (including CJK, Cyrillic, etc.) and only remove specific
22+
punctuation that might interfere with the ellipsis display.
2423
*/
25-
export const removeLeadingNonAlphanumeric = (path: string): string => path.replace(/^[^a-zA-Z0-9]+/, "")
24+
export const removeLeadingNonAlphanumeric = (path: string): string => {
25+
// Only remove specific punctuation characters that might interfere with ellipsis display
26+
// Keep all language characters (including CJK, Cyrillic, etc.) and numbers
27+
return path.replace(/^[/\\:*?"<>|]+/, "")
28+
}
2629

2730
const CodeAccordian = ({
2831
code,

0 commit comments

Comments
 (0)