File tree 4 files changed +33
-2
lines changed
4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ function isUrlRequest(url) {
199
199
// An URL is not an request if
200
200
201
201
// It is not http or https
202
- if ( ! / ^ h t t p s ? : / i . test ( url ) ) {
202
+ if ( ! / ^ [ a - z A - Z ] [ a - z A - Z \d + \- . ] * : / . test ( url ) ) {
203
203
return false ;
204
204
}
205
205
Original file line number Diff line number Diff line change @@ -262,6 +262,33 @@ describe("HMR", () => {
262
262
} , 100 ) ;
263
263
} ) ;
264
264
265
+ it ( "should reloads with browser extension protocol" , ( done ) => {
266
+ document . head . innerHTML =
267
+ '<link rel="stylesheet" href="/dist/main.css" /><link rel="stylesheet" href="chrome-extension://main.css" />' ;
268
+
269
+ const update = hotModuleReplacement ( "./src/style.css" , { } ) ;
270
+
271
+ update ( ) ;
272
+
273
+ setTimeout ( ( ) => {
274
+ expect ( console . log . mock . calls [ 0 ] [ 0 ] ) . toMatchSnapshot ( ) ;
275
+
276
+ const links = Array . prototype . slice . call (
277
+ document . querySelectorAll ( "link" )
278
+ ) ;
279
+
280
+ expect ( links [ 0 ] . visited ) . toBe ( true ) ;
281
+ expect ( document . head . innerHTML ) . toMatchSnapshot ( ) ;
282
+
283
+ links [ 1 ] . dispatchEvent ( getLoadEvent ( ) ) ;
284
+
285
+ expect ( links [ 1 ] . isLoaded ) . toBe ( true ) ;
286
+ expect ( links [ 2 ] . visited ) . toBeUndefined ( ) ;
287
+
288
+ done ( ) ;
289
+ } , 100 ) ;
290
+ } ) ;
291
+
265
292
it ( "should reloads with non-file script in the end of page" , ( done ) => {
266
293
document . body . appendChild ( document . createElement ( "script" ) ) ;
267
294
Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ exports[`HMR should reloads with absolute remove url 1`] = `"[HMR] css reload %s
12
12
13
13
exports[`HMR should reloads with absolute remove url 2`] = `"<link rel =\\"stylesheet\\" href =\\"/dist/main.css\\"><link rel =\\"stylesheet\\" href =\\"http://localhost/dist/main.css?1479427200000\\"><link rel =\\"stylesheet\\" href =\\"http://dev.com/dist/main.css\\">"`;
14
14
15
+ exports[`HMR should reloads with browser extension protocol 1`] = `"[HMR] css reload %s"`;
16
+
17
+ exports[`HMR should reloads with browser extension protocol 2`] = `"<link rel =\\"stylesheet\\" href =\\"/dist/main.css\\"><link rel =\\"stylesheet\\" href =\\"http://localhost/dist/main.css?1479427200000\\"><link rel =\\"stylesheet\\" href =\\"chrome-extension://main.css\\">"`;
18
+
15
19
exports[`HMR should reloads with link without href 1`] = `"[HMR] css reload %s"`;
16
20
17
21
exports[`HMR should reloads with link without href 2`] = `"<link rel =\\"stylesheet\\" href =\\"/dist/main.css\\"><link rel =\\"stylesheet\\" href =\\"http://localhost/dist/main.css?1479427200000\\"><link rel =\\"shortcut icon\\">"`;
Original file line number Diff line number Diff line change @@ -220,7 +220,7 @@ function isUrlRequest(url) {
220
220
// An URL is not an request if
221
221
222
222
// It is not http or https
223
- if ( ! / ^ h t t p s ? : / i . test ( url ) ) {
223
+ if ( ! / ^ [ a - z A - Z ] [ a - z A - Z \d + \- . ] * : / . test ( url ) ) {
224
224
return false ;
225
225
}
226
226
You can’t perform that action at this time.
0 commit comments