MCPcopy Create free account
hub / github.com/WICG/webpackage / validateOptions

Function validateOptions

js/bundle/src/cli.ts:108–132  ·  view source on GitHub ↗
(options: any)

Source from the content-addressed store, hash-verified

106}
107
108function 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
134function readHeaderOverridesFile(path: string): unknown {
135 try {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected