Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append segments #409

Open
blaadje opened this issue Apr 29, 2021 · 0 comments
Open

Append segments #409

blaadje opened this issue Apr 29, 2021 · 0 comments

Comments

@blaadje
Copy link

blaadje commented Apr 29, 2021

Hey, awesome lib,
Why is it not possible to append multiple segments tho ? Maybe there's a logic behind that or I missed something.

const API_BASE_URL = new URI('https://api-staging.foo.fr/v1/foo')

const customUrl = API_BASE_URL()
  .clone()
  .segment([ 'name', 'customer', 'whatever' ]) // <- it replaces existing `v1/foo` path :(
  .toString() // => https://api-staging.foo.fr/name/customer/whatever
        
// actual not so elegant solution
const customUrl = API_BASE_URL()
  .clone()
  .segment('name') 
  .segment('customer') 
  .segment('whatever')  // <- I dont find it really relevant
  .toString() // => https://api-staging.foo.fr/v1/foo/name/customer/whatever
  
// proposal
const customUrl = API_BASE_URL()
  .clone()
  .appendSegment([ 'name', 'customer', 'whatever' ]) 
  .toString() // => https://api-staging.foo.fr/v1/foo/name/customer/whatever
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant