You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@ctrl/url-join

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ctrl/url-join

Join strings together and normalize the resulting url


Version published
Weekly downloads
1.2K
increased by30.86%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

url-join npm coverage

A typescript fork of jfromaniello/url-join with additional options.

Install

npm install @ctrl/url-join

Use

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.

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

See Also

Keywords

FAQs

Package last updated on 06 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc