(query: string)
| 1 | /** A repository-relative path request, kept intact instead of split into words. */ |
| 2 | export function fileQueryPath(query: string): string | undefined { |
| 3 | const path = query.trim().replace(/\\/g, '/').replace(/^(?:\.\/)+/, ''); |
| 4 | if (!path || path.startsWith('/') || path.endsWith('/') || /^[A-Za-z]:/.test(path) |
| 5 | || /[\x00-\x1f]/.test(path) || path.split('/').some(part => !part || part === '..' || part === '.')) return undefined; |
| 6 | return path.includes('/') || /\.[^\s.]+$/.test(path) ? path : undefined; |
| 7 | } |
no outgoing calls
no test coverage detected