Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another flash of unstyled content #927

Merged
merged 3 commits into from
Apr 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/react-server/core/util/ClientCssHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,16 @@ module.exports = {
}

function normalizeLocalUrl(url) {
const urlBase = location.protocol + "//" + location.host;

// The browser will give us a full URL even if we only put a
// Step 1: make the url protocol less first. This helps recognizing http://0.0.0.0:3001/common.css
// and //0.0.0.0:3001/common.css as the same file.
// Step 2: The browser will give us a full URL even if we only put a
// path in on the server. So, if we're comparing against just
// a path here we need to strip the base off to avoid a flash
// of unstyled content.
if (url && url.indexOf(urlBase) === 0) {
url = url.substr(urlBase.length);
if (typeof url === 'string') {
url = url
.replace(/^http[s]?:/, '')
.replace(new RegExp("^\/\/" + location.host), '');
}

return url;
Expand Down