url_join

Package Version Hex Docs

Join URL path segments and normalize the result, similar to npm’s url-join.

Installation

gleam add url_join

Usage

import url_join

pub fn main() -> Nil {
  // Join segments and normalize slashes, protocol, query, and hash
  let url =
    url_join.join([
      "http://www.google.com",
      "a",
      "/b/cd",
      "?foo=123",
    ])
  // -> "http://www.google.com/a/b/cd?foo=123"

  let api =
    url_join.join([
      "https://example.com/",
      "/api/",
      "users",
    ])
  // -> "https://example.com/api/users"
}

Behaviour

Further documentation can be found at https://hexdocs.pm/url_join.

Development

gleam run   # Run the project
gleam test  # Run the tests
Search Document