File tree Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ function isUrlRequest(url) {
199199 // An URL is not an request if
200200
201201 // 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 ) ) {
203203 return false ;
204204 }
205205
Original file line number Diff line number Diff line change @@ -262,6 +262,33 @@ describe("HMR", () => {
262262 } , 100 ) ;
263263 } ) ;
264264
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+
265292 it ( "should reloads with non-file script in the end of page" , ( done ) => {
266293 document . body . appendChild ( document . createElement ( "script" ) ) ;
267294
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
1212
1313exports[`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\\">"`;
1414
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+
1519exports[`HMR should reloads with link without href 1`] = `"[HMR] css reload %s"`;
1620
1721exports[`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) {
220220 // An URL is not an request if
221221
222222 // 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 ) ) {
224224 return false ;
225225 }
226226
You can’t perform that action at this time.
0 commit comments