Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ func (opts *HandlerOpts) validate() error {
}

func NormalizePathPrefix(prefix string) string {
if prefix == "" {
return "/"
if prefix == "" || prefix == "/" {
return ""
}
prefix = strings.TrimSuffix(prefix, "/")
if !strings.HasPrefix(prefix, "/") {
return "/" + prefix
prefix = "/" + prefix
}
return prefix
}
Expand Down Expand Up @@ -189,7 +189,7 @@ func NewHandler(opts *HandlerOpts) (*Handler, error) {
JobListHideArgsByDefault: opts.JobListHideArgsByDefault,
})

prefix := cmp.Or(strings.TrimSuffix(opts.Prefix, "/"), "")
prefix := opts.Prefix

frontendIndex, err := fs.Sub(FrontendIndex, "dist")
if err != nil {
Expand Down Expand Up @@ -266,7 +266,7 @@ func NewHandler(opts *HandlerOpts) (*Handler, error) {

middlewareStack := apimiddleware.NewMiddlewareStack()

if prefix != "/" {
if prefix != "" {
middlewareStack.Use(&stripPrefixMiddleware{prefix})
}

Expand Down
2 changes: 1 addition & 1 deletion internal/riveruicmd/riveruicmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func initServer[TClient any](ctx context.Context, opts *initServerOpts, createCl
})
filters := []sloghttp.Filter{}
if opts.silentHealthChecks {
apiHealthPrefix := strings.TrimSuffix(opts.pathPrefix, "/") + "/api/health-checks"
apiHealthPrefix := opts.pathPrefix + "/api/health-checks"
filters = append(filters, sloghttp.IgnorePathPrefix(apiHealthPrefix))
}
logHandler := sloghttp.NewWithConfig(opts.logger, sloghttp.Config{
Expand Down
Loading