| 106 | } |
| 107 | |
| 108 | function validateOptions(options: any): string | null { |
| 109 | if (options.baseURL && !options.baseURL.endsWith('/')) { |
| 110 | return "error: baseURL must end with '/'."; |
| 111 | } |
| 112 | |
| 113 | if ( |
| 114 | options.formatVersion !== undefined && |
| 115 | !APPROVED_VERSIONS.includes(options.formatVersion) |
| 116 | ) { |
| 117 | return ( |
| 118 | 'error: invalid format version (must be ' + |
| 119 | APPROVED_VERSIONS.map((val) => `"${val}"`).join(' or ') + |
| 120 | ').' |
| 121 | ); |
| 122 | } |
| 123 | |
| 124 | if ( |
| 125 | options.formatVersion === B1 && |
| 126 | !(options.primaryURL || options.baseURL) |
| 127 | ) { |
| 128 | return 'error: Primary URL is required.'; |
| 129 | } |
| 130 | |
| 131 | return null; |
| 132 | } |
| 133 | |
| 134 | function readHeaderOverridesFile(path: string): unknown { |
| 135 | try { |