Join strings together and normalize the resulting url
npm install @ctrl/url-join> A typescript fork of jfromaniello/url-join with additional options.
npm install @ctrl/url-join
`$3
`ts
import { urlJoin } from '@ctrl/url-join';const url = urlJoin('http://www.example.com', 'a', '/b/cd', '?foo=123')
// http://www.example.com/a/b/cd?foo=123
`##### Preserve trailing slash
Preserves trailing slashes between each provided string. Not recommended with query parameters.
`ts
import { customUrlJoin } from '@ctrl/url-join';const trailingUrlJoin = customUrlJoin({ trailingSlash: true });
trailingUrlJoin('https://example.com', 'results', '/')
// https://example.com/results/
trailingUrlJoin('https://example.com', '#foobar')
// https://example.com/#foobar
trailingUrlJoin('https://example.com', '#', 'foobar')
// https://example.com/#/foobar
trailingUrlJoin('https://example.com', 'results', '?q=foo', '&page=1')
// https://example.com/results/?q=foo/&page=1 - Probably not what you want
``