Skip to content

url commands: inconsistencies and missing features #14162

Closed

Description

@Bahex

Related problem

  • There is no built-in counterpart to url build-query for splitting a query string (though this is not hard to implement in nushell)

  • url join's handling of parameters don't match url build-query, specifically it doesn't support lists

  • url parse can create records with duplicate keys

    > "http://host?a=1&b=2&b=3" | url parse | get params
    ╭───┬───╮
    │ a │ 1 │
    │ b │ 2 │
    │ b │ 3 │
    ╰───┴───╯

Describe the solution you'd like

  • provide url split-query either as a built-in or as a std function

    def "url split-query" []: [string -> table<key: string, value: string>] {
      split row '&'
      | split column '=' -n 2 key value
      | update cells { url decode }
    }
  • url join and url build-query should use a common implementation.

  • url parse's params should either:

    • group the same keys into a list.
    • instead of a record, be a key-value table. (table<key: string, value: string>)

    second option seems preferable as it would preserve order of parameters, which might carry meaning in different APIs

  • if url parse | get params returns a table<key:string, value:string>, url join should also support the same in its input.

Describe alternatives you've considered

No response

Additional context and details

No response

Activity

  1. added
    category:enhancement
    status:needs-triage
    on Oct 23, 2024
  2. added
    A:networking
    on Oct 24, 2024
  3. added this to the v0.100.0 milestone on Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:networkingcategory:enhancementstatus:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions