(raw, fallbackName)
| 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 |
no test coverage detected