11import { VULNERABILITIES_URL } from '#site/next.constants.mjs' ;
2+ import { fetchWithRetry } from '#site/util/fetch' ;
23
34const RANGE_REGEX = / ( [ < > ] = ? ) \s * ( \d + ) (?: \. ( \d + ) ) ? / ;
5+ const V0_REGEX = / ^ 0 \. \d + ( \. x ) ? $ / ;
6+ const VER_REGEX = / ^ \d + \. x $ / ;
47
58/**
69 * Fetches vulnerability data from the Node.js Security Working Group repository,
@@ -9,7 +12,7 @@ const RANGE_REGEX = /([<>]=?)\s*(\d+)(?:\.(\d+))?/;
912 * @returns {Promise<import('#site/types/vulnerabilities').GroupedVulnerabilities> } Grouped vulnerabilities
1013 */
1114export default ( ) =>
12- fetch ( VULNERABILITIES_URL )
15+ fetchWithRetry ( VULNERABILITIES_URL )
1316 . then ( response => response . json ( ) )
1417 . then ( payload => {
1518 /** @type {Array<import('#site/types/vulnerabilities').RawVulnerability> } */
@@ -27,14 +30,14 @@ export default () =>
2730 // Helper function to process version patterns
2831 const processVersion = ( version , vulnerability ) => {
2932 // Handle 0.X versions (pre-semver)
30- if ( / ^ 0 \. \d + ( \. x ) ? $ / . test ( version ) ) {
33+ if ( V0_REGEX . test ( version ) ) {
3134 addToGroup ( '0' , vulnerability ) ;
3235
3336 return ;
3437 }
3538
3639 // Handle simple major.x patterns (e.g., 12.x)
37- if ( / ^ \d + \. x $ / . test ( version ) ) {
40+ if ( VER_REGEX . test ( version ) ) {
3841 const majorVersion = version . split ( '.' ) [ 0 ] ;
3942
4043 addToGroup ( majorVersion , vulnerability ) ;
@@ -79,5 +82,4 @@ export default () =>
7982 }
8083
8184 return grouped ;
82- } )
83- . catch ( ( ) => ( { } ) ) ;
85+ } ) ;
0 commit comments