File tree Expand file tree Collapse file tree 1 file changed +21
-7
lines changed
Expand file tree Collapse file tree 1 file changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ function updateCss(el, url) {
9090 url = el . href . split ( '?' ) [ 0 ] ;
9191 }
9292
93- if ( isDataURL ( url ) ) {
93+ if ( ! isUrlRequest ( url ) ) {
9494 return ;
9595 }
9696
@@ -147,7 +147,7 @@ function reloadStyle(src) {
147147 forEach . call ( elements , function ( el ) {
148148 var url = getReloadUrl ( el . href , src ) ;
149149
150- if ( isDataURL ( url ) ) {
150+ if ( ! isUrlRequest ( url ) ) {
151151 return ;
152152 }
153153
@@ -176,11 +176,25 @@ function reloadAll() {
176176 } ) ;
177177}
178178
179- function isDataURL ( s ) {
180- return ! ! s . match (
181- // eslint-disable-next-line no-useless-escape
182- / ^ \s * d a t a : ( [ a - z ] + \/ [ a - z 0 - 9 - + .] + ( ; [ a - z - ] + = [ a - z 0 - 9 - ] + ) ? ) ? ( ; b a s e 6 4 ) ? , ( [ a - z 0 - 9 ! $ & ' , ( ) * + ; = \- . _ ~ : @ \/ ? % \s ] * ) \s * $ / i
183- ) ;
179+ function isUrlRequest ( url ) {
180+ // An URL is not an request if
181+
182+ // 1. It's an absolute url
183+ if ( / ^ [ a - z ] [ a - z 0 - 9 + . - ] * : / i. test ( url ) ) {
184+ return false ;
185+ }
186+
187+ // 2. It's a protocol-relative
188+ if ( / ^ \/ \/ / . test ( url ) ) {
189+ return false ;
190+ }
191+
192+ // 3. Its a `#` link
193+ if ( / ^ # / . test ( url ) ) {
194+ return false ;
195+ }
196+
197+ return true ;
184198}
185199
186200module . exports = function ( moduleId , options ) {
You can’t perform that action at this time.
0 commit comments