Skip to content

Commit 1c43763

Browse files
authored
Merge pull request redfin#927 from SoprisApps/patch-fix-clientcsshelper-key-issue
Another flash of unstyled content
2 parents 2952101 + 4bfd03c commit 1c43763

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/react-server/core/util/ClientCssHelper.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,16 @@ module.exports = {
9696
}
9797

9898
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
102102
// path in on the server. So, if we're comparing against just
103103
// a path here we need to strip the base off to avoid a flash
104104
// 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(/^http[s]?:/, '')
108+
.replace(new RegExp("^\/\/" + location.host), '');
107109
}
108110

109111
return url;

0 commit comments

Comments
 (0)