File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -104,14 +104,16 @@ function findMatchingRule(url: string): RuntimeRetryOptions {
104104 // Check test condition
105105 let tester = rule . test ;
106106 if ( tester ) {
107- if ( typeof tester === 'string' ) {
108- const regexp = new RegExp ( tester ) ;
109- tester = ( str : string ) => regexp . test ( str ) ;
107+ if ( tester instanceof RegExp ) {
108+ if ( ! tester . test ( url ) ) continue ;
109+ } else if ( typeof tester === 'string' ) {
110+ const regexp = new RegExp ( tester ) ;
111+ tester = ( str : string ) => regexp . test ( str ) ;
110112 }
111- if ( typeof tester !== 'function' || ! tester ( url ) ) {
112- continue ;
113- }
114- }
113+ if ( typeof tester === 'function' && ! tester ( url ) ) {
114+ continue ;
115+ }
116+ }
115117
116118 // Check domain condition
117119 const domain = findCurrentDomain ( url , rule . domain || [ ] ) ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export type PluginAssetsRetryOptions = {
1414 /**
1515 * The test function of the asset to be retried.
1616 */
17- test ?: string | ( ( url : string ) => boolean ) ;
17+ test ?: string | RegExp | ( ( url : string ) => boolean ) ;
1818 /**
1919 * Specifies the retry domain when assets fail to load.
2020 */
You can’t perform that action at this time.
0 commit comments