File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,12 @@ const downloadFile = async (url: string): Promise<Buffer> => {
5454 return Buffer . from ( response . data )
5555}
5656
57+ // Request document headers
58+ const requestHead = async ( url : string ) => {
59+ const response = await axios . head ( url )
60+ return response . headers
61+ }
62+
5763// Function to generate SRI hash
5864const generateSRI = ( content : Buffer , algorithm : string = 'sha512' ) : string => {
5965 const hash = crypto . createHash ( algorithm ) . update ( content ) . digest ( 'base64' )
@@ -141,14 +147,21 @@ const buildRegistryEntry = async (
141147 const integrity = await generateSRIFromURL ( source )
142148 if ( ! integrity ) return null
143149
150+ let optionsSchema = `${ cdnBase } /${ path . dirname ( mainFile ) } /artalk-plugin-options.schema.json`
151+ try {
152+ await requestHead ( optionsSchema )
153+ } catch {
154+ optionsSchema = '' // unset if returns 404
155+ }
156+
144157 distEntry = {
145158 ...distEntry ,
146159 version,
147160 source,
148161 integrity,
149162 updated_at : npmInfo [ 'time' ] [ version ] ,
150163 min_artalk_version : extractMinArtalkClientVersion ( npmPkgData ) ,
151- options_schema : ` ${ cdnBase } / ${ path . dirname ( mainFile ) } /artalk-plugin-options.schema.json` ,
164+ options_schema : optionsSchema ,
152165 }
153166 }
154167
You can’t perform that action at this time.
0 commit comments