(value: unknown, fallback: string)
| 52 | } |
| 53 | |
| 54 | export function normalizeImportName(value: unknown, fallback: string): string { |
| 55 | const raw = typeof value === 'string' ? value : '' |
| 56 | let name = [...raw.trim()] |
| 57 | .map(char => |
| 58 | INVALID_NAME_CHARS.has(char) || char.charCodeAt(0) <= 0x1F ? '-' : char, |
| 59 | ) |
| 60 | .join('') |
| 61 | name = name |
| 62 | .replace(/^\.+/, '') |
| 63 | .replace(/[. ]+$/g, '') |
| 64 | .trim() |
| 65 | |
| 66 | if (!name || name === '.' || name === '..') { |
| 67 | name = fallback |
| 68 | } |
| 69 | |
| 70 | if (WINDOWS_RESERVED_NAME_RE.test(name)) { |
| 71 | name = `${name} item` |
| 72 | } |
| 73 | |
| 74 | return name |
| 75 | } |
| 76 | |
| 77 | export function normalizeHttpMethod( |
| 78 | value: unknown, |
no outgoing calls
no test coverage detected