Fix URL generation for subdir deployments
We discovered that the build process strips trailing slashes from PUBLIC_URL, which thwarted our plans in getHomepageUrl. This ensures the function always returns a trailing slash. Change-Id: I03c4ec79ee4566a8b7fbd4e04c18e86f4257fa8f
This commit is contained in:
parent
633b63b50f
commit
95814f7734
|
@ -40,7 +40,9 @@ function getHomepageUrl() {
|
|||
} else {
|
||||
url.pathname = ''
|
||||
}
|
||||
|
||||
if (!url.pathname.endsWith('/')) {
|
||||
url.pathname = url.pathname + '/'
|
||||
}
|
||||
return url.origin + url.pathname
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,10 @@ it('should return the subdir homepage url', () => {
|
|||
Object.defineProperty(window, 'location', {
|
||||
value: new URL(homepage)
|
||||
} )
|
||||
// The build process strips trailing slashes from PUBLIC_URL,
|
||||
// so make sure we don't include any in our tests
|
||||
Object.defineProperty(process.env, 'PUBLIC_URL', {
|
||||
value: '/zuul/'
|
||||
value: '/zuul'
|
||||
} )
|
||||
|
||||
// Test some of the known, possible, URLs to verify
|
||||
|
|
Loading…
Reference in New Issue