MCPcopy Create free account
hub / github.com/cosscom/coss / fixFilePaths

Function fixFilePaths

apps/ui/lib/registry.ts:124–143  ·  view source on GitHub ↗
(files: RegistryFile[])

Source from the content-addressed store, hash-verified

122}
123
124function fixFilePaths(files: RegistryFile[]) {
125 if (!files) {
126 return [];
127 }
128
129 // Resolve all paths relative to the first file's directory.
130 const firstFilePath = files[0]?.path;
131 if (!firstFilePath) {
132 return [];
133 }
134 const firstFilePathDir = path.dirname(firstFilePath);
135
136 return files.map((file) => {
137 return {
138 ...file,
139 path: path.relative(firstFilePathDir, file.path),
140 target: getFileTarget(file),
141 };
142 });
143}
144
145export function fixImport(content: string) {
146 const regex = /@\/(.+?)\/((?:.*?\/)?(?:components|ui|hooks|lib))\/([\w-]+)/g;

Callers 1

getRegistryItemFunction · 0.85

Calls 1

getFileTargetFunction · 0.85

Tested by

no test coverage detected