MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / formatDisplayPath

Function formatDisplayPath

webview-ui/src/components/common/ImageViewer.tsx:156–169  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

154 * Format the display path for the image
155 */
156 const formatDisplayPath = (path: string): string => {
157 // If it's already a relative path starting with ./, keep it
158 if (path.startsWith("./")) return path
159 // If it's an absolute path, extract the relative portion
160 // Look for workspace patterns - match the last segment after any directory separator
161 const workspaceMatch = path.match(/\/([^/]+)\/(.+)$/)
162 if (workspaceMatch && workspaceMatch[2]) {
163 // Return relative path from what appears to be the workspace root
164 return `./${workspaceMatch[2]}`
165 }
166 // Otherwise, just get the filename
167 const filename = path.split("/").pop()
168 return filename || path
169 }
170
171 // Handle missing image URI
172 if (!imageUri) {

Callers 1

ImageViewerFunction · 0.85

Calls 1

popMethod · 0.80

Tested by

no test coverage detected