( name: string, )
| 60 | } |
| 61 | |
| 62 | export function getEntryNameValidationIssue( |
| 63 | name: string, |
| 64 | ): EntryNameValidationIssue | null { |
| 65 | const normalizedName = normalizeEntryName(name) |
| 66 | |
| 67 | if (!normalizedName || normalizedName === '.' || normalizedName === '..') { |
| 68 | return { code: 'empty' } |
| 69 | } |
| 70 | |
| 71 | if (normalizedName.startsWith('.')) { |
| 72 | return { code: 'leadingDot' } |
| 73 | } |
| 74 | |
| 75 | const invalidChars = findInvalidEntryNameChars(normalizedName) |
| 76 | |
| 77 | if (invalidChars.length) { |
| 78 | return { |
| 79 | code: 'invalidChars', |
| 80 | chars: invalidChars, |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | if (normalizedName.endsWith('.')) { |
| 85 | return { code: 'trailingDot' } |
| 86 | } |
| 87 | |
| 88 | if (WINDOWS_RESERVED_NAME_RE.test(normalizedName)) { |
| 89 | return { code: 'windowsReserved' } |
| 90 | } |
| 91 | |
| 92 | return null |
| 93 | } |
no test coverage detected