1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 'use strict';
- const { URL } = require('url');
- module.exports = getPublicUrlOrPath;
- function getPublicUrlOrPath(isEnvDevelopment, homepage, envPublicUrl) {
- const stubDomain = 'https://create-react-app.dev';
- if (envPublicUrl) {
-
- envPublicUrl = envPublicUrl.endsWith('/')
- ? envPublicUrl
- : envPublicUrl + '/';
-
-
- const validPublicUrl = new URL(envPublicUrl, stubDomain);
- return isEnvDevelopment
- ? envPublicUrl.startsWith('.')
- ? '/'
- : validPublicUrl.pathname
- :
-
- envPublicUrl;
- }
- if (homepage) {
-
- homepage = homepage.endsWith('/') ? homepage : homepage + '/';
-
- const validHomepagePathname = new URL(homepage, stubDomain).pathname;
- return isEnvDevelopment
- ? homepage.startsWith('.')
- ? '/'
- : validHomepagePathname
- :
-
- homepage.startsWith('.')
- ? homepage
- : validHomepagePathname;
- }
- return '/';
- }
|