mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-15 18:59:33 +01:00
fix(preview): a shell prompt's trailing $ or # stays out of its folder link (#604 merge-time fix)
The folder link pattern treats `:` as a boundary and allows `$`/`#` in a path, so every default bash prompt (`user@host:~/proj$`, `root@c:/workspace#`) became a folder link to a path that does not exist, and clicking it showed "Folder not found". folderLinkPath now strips them, so the link opens the prompt's cwd. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
076f62fa1b
commit
9c56f7823d
2 files changed
+8
-1
No files matched your search
@@ -2163,7 +2163,9 @@ const FOLDER_PATH_LINK_PATTERN =
|
||||
* without a slash at the end is prose, not a folder.
|
||||
*/
|
||||
function folderLinkPath(candidate) {
|
||||
const path = String(candidate || '').replace(/[.,:;!?'"]+$/, '');
|
||||
// `$` and `#` too: a shell prompt (`user@host:~/proj$ `, `root@c:/app# `) ends
|
||||
// its cwd with one. A folder whose name really ends in one links one short.
|
||||
const path = String(candidate || '').replace(/[.,:;!?'"$#]+$/, '');
|
||||
if (!path || path === '~/' || /^\/[^/]+\/$/.test(path)) return null;
|
||||
if (path.endsWith('/')) return /[^/.]/.test(path) ? path : null;
|
||||
if (!path.startsWith('/') && !path.startsWith('~/')) return null;
|
||||
|
||||
Reference in new issue
Block a user