File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
packages/react-server/core/util Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -96,14 +96,16 @@ module.exports = {
96
96
}
97
97
98
98
function normalizeLocalUrl ( url ) {
99
- const urlBase = location . protocol + "//" + location . host ;
100
-
101
- // The browser will give us a full URL even if we only put a
99
+ // Step 1: make the url protocol less first. This helps recognizing http://0.0.0.0:3001/common.css
100
+ // and //0.0.0.0:3001/common.css as the same file.
101
+ // Step 2: The browser will give us a full URL even if we only put a
102
102
// path in on the server. So, if we're comparing against just
103
103
// a path here we need to strip the base off to avoid a flash
104
104
// of unstyled content.
105
- if ( url && url . indexOf ( urlBase ) === 0 ) {
106
- url = url . substr ( urlBase . length ) ;
105
+ if ( typeof url === 'string' ) {
106
+ url = url
107
+ . replace ( / ^ h t t p [ s ] ? : / , '' )
108
+ . replace ( new RegExp ( "^\/\/" + location . host ) , '' ) ;
107
109
}
108
110
109
111
return url ;
You can’t perform that action at this time.
0 commit comments