(path, needsSlash)
| 12 | const envPublicUrl = process.env.PUBLIC_URL; |
| 13 | |
| 14 | function ensureSlash(path, needsSlash) { |
| 15 | const hasSlash = path.endsWith('/'); |
| 16 | if (hasSlash && !needsSlash) { |
| 17 | return path.substr(path, path.length - 1); |
| 18 | } else if (!hasSlash && needsSlash) { |
| 19 | return `${path}/`; |
| 20 | } else { |
| 21 | return path; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | const getPublicUrl = appPackageJson => |
| 26 | envPublicUrl || require(appPackageJson).homepage; |