Handle basepath issue with missing slash

pull/4812/head
Brandon Farmer 2018-11-09 16:03:17 -08:00
parent 573cdff30a
commit 7bcffde792
2 changed files with 8 additions and 2 deletions

View File

@ -47,8 +47,9 @@ func NewMux(opts MuxOpts, service Service) http.Handler {
})
if opts.Basepath != "" {
basePath := fmt.Sprintf("%s/", opts.Basepath)
// Prefix any URLs found in the React assets with any configured basepath
assets = NewDefaultURLPrefixer(opts.Basepath, assets, opts.Logger)
assets = NewDefaultURLPrefixer(basePath, assets, opts.Logger)
}
// Compress the assets with gzip if an accepted encoding

View File

@ -6,7 +6,12 @@ export const getBasepath = () => {
return ''
}
return rootNode.getAttribute('data-basepath') || ''
let basepath = rootNode.getAttribute('data-basepath') || ''
if (basepath !== '') {
basepath = basepath.slice(0, basepath.length - 1)
}
return basepath
}
export const stripPrefix = (pathname, basepath = getBasepath()) => {