fix(web): show artifact paths relative to the workspace
This commit is contained in:
1 parent
b27d861741
commit
5b671d7df3
19 files changed
+80
-36
No files matched your search
@@ -97,3 +97,16 @@ export function fileAddressFor(sessionId: string, cwd: string | undefined, path:
|
||||
if (root !== '' && normalized.startsWith(`${root}/`)) return sessionFileAddress(sessionId, normalized.slice(root.length + 1))
|
||||
return sessionFileAddress(sessionId, normalized)
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip the workspace root from a workspace-rooted absolute path (display only).
|
||||
* @param text - the path to shorten.
|
||||
* @param cwd - session workspace root; absent or empty leaves the path unchanged.
|
||||
* @returns the path relative to the workspace root, or unchanged when it is not rooted there.
|
||||
*/
|
||||
export function relativizeToCwd(text: string, cwd: string | undefined): string {
|
||||
if (cwd === undefined || cwd === '') return text
|
||||
const root = cwd.replace(/[/\\]+$/, '')
|
||||
if (text.startsWith(`${root}/`) || text.startsWith(`${root}\\`)) return text.slice(root.length + 1)
|
||||
return text
|
||||
}
|
||||
Reference in new issue
Block a user