MCPcopy Create free account
hub / github.com/error311/FileRise / sanitizeRelativePath

Function sanitizeRelativePath

public/js/sharedDropView.js:265–283  ·  view source on GitHub ↗
(raw, fallbackName)

Source from the content-addressed store, hash-verified

263 }
264
265 function sanitizeRelativePath(raw, fallbackName) {
266 let path = String(raw || '').replace(/\\/g, '/').trim();
267 path = path.replace(/^\/+/, '').replace(/\/+$/, '');
268 if (!path) return fallbackName;
269 path = path.replace(/\/+/g, '/');
270 const parts = path.split('/').filter(Boolean);
271 const clean = [];
272 for (let i = 0; i < parts.length; i++) {
273 const seg = parts[i].trim();
274 if (!seg || seg === '.' || seg === '..') {
275 continue;
276 }
277 clean.push(seg);
278 }
279 if (!clean.length) {
280 return fallbackName;
281 }
282 return clean.join('/');
283 }
284
285 function getRelativePathForItem(file) {
286 const raw = preserveFolderStructure

Callers 2

getRelativePathForItemFunction · 0.85
enqueueFilesFunction · 0.85

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected