Skip to content
This repository has been archived by the owner on Mar 18, 2023. It is now read-only.

Config endpoint assumes path will not end with / #150

Open
msavy opened this issue Aug 7, 2022 · 0 comments
Open

Config endpoint assumes path will not end with / #150

msavy opened this issue Aug 7, 2022 · 0 comments

Comments

@msavy
Copy link
Member

msavy commented Aug 7, 2022

A valid URL such as http://localhost:8080/apiman/ in config.json5 endpoint (and possibly others) causes 'double forward slash', as UI code adds a / to the end of endpoint.

For example: http://localhost:8080/apiman/ causes http://locahost:8080/apiman//<rest of path>

Acceptance criteria

  • URL should be normalised so that slashed and non-slashed URLs work.

Possible solutions

  • Normalise by always trimming the slash from endpoints in #get<whatever> URL endpoints, (consistently throughout codebase so all config properties do the same).
  • Use built-in URL class to join URLs instead of doing it by hand new URL('/whatever', 'http://localhost:8080/apiman/').href
new URL('/whatever', 'http://localhost:8080/apiman/').href 
'http://localhost:8080/whatever'
new URL('/whatever', 'http://localhost:8080/apiman').href 
'http://localhost:8080/whatever'

Might be good to hide some of this behind the scenes, with an extra service endpoint like

getEndpoint(path: string): string { 
   return new URL(path, getEndpoint());
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant