Skip to content

Append segments #409

Description

@blaadje

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions