Skip to content

Commit 52e2f7d

Browse files
author
Enoah Netzach
committed
Simplify served path choice logic
1 parent b1614b2 commit 52e2f7d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/react-scripts/config/paths.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var nodePaths = (process.env.NODE_PATH || '')
4444
var envPublicUrl = process.env.PUBLIC_URL;
4545

4646
function getPublicUrl(appPackageJson) {
47-
return envPublicUrl ? envPublicUrl : require(appPackageJson).homepage;
47+
return envPublicUrl || require(appPackageJson).homepage;
4848
}
4949

5050
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
@@ -54,9 +54,13 @@ function getPublicUrl(appPackageJson) {
5454
// We can't use a relative path in HTML because we don't want to load something
5555
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
5656
function getServedPath(appPackageJson) {
57-
var homepagePath = getPublicUrl(appPackageJson);
58-
var homepagePathname = homepagePath ? url.parse(homepagePath).pathname : '/';
59-
return envPublicUrl ? homepagePath : homepagePathname;
57+
var publicUrl = getPublicUrl(appPackageJson)
58+
if (!publicUrl) {
59+
return '/'
60+
} else if (envPublicUrl) {
61+
return publicUrl;
62+
}
63+
return url.parse(publicUrl).pathname;
6064
}
6165

6266
// config after eject: we're in ./config/

0 commit comments

Comments
 (0)