Socket
Socket
Sign inDemoInstall

url-join

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

url-join

Join urls and normalize as in path.join.


Version published
Weekly downloads
7.8M
increased by6.74%
Maintainers
1
Weekly downloads
 
Created

What is url-join?

The url-join npm package is a utility for joining and normalizing URLs. It is particularly useful when constructing URLs dynamically, ensuring that the resulting URL is correctly formatted without duplicated slashes or missing segments. This package can handle various scenarios, including joining multiple parts of a URL, handling query strings, and ensuring the correct inclusion of protocols.

What are url-join's main functionalities?

Joining URL segments

This feature allows for the concatenation of multiple segments into a single, well-formed URL. It automatically handles the insertion or removal of slashes as needed between segments.

"const urlJoin = require('url-join');\nconst fullUrl = urlJoin('http://example.com', 'a', '/b/cd', '?foo=123');\nconsole.log(fullUrl); // Outputs: http://example.com/a/b/cd?foo=123"

Handling trailing slashes

This feature ensures that trailing slashes are correctly handled, either preserving them or removing them based on the input segments, thus maintaining the intended URL structure.

"const urlJoin = require('url-join');\nconst fullUrl = urlJoin('http://example.com/', '/a/b/', '/');\nconsole.log(fullUrl); // Outputs: http://example.com/a/b/"

Combining URL with query parameters

This feature demonstrates how url-join can be used to append query parameters to a base URL, ensuring that the '?' character is correctly placed and that the overall URL remains well-formed.

"const urlJoin = require('url-join');\nconst fullUrl = urlJoin('http://example.com', 'search', '?q=url+join');\nconsole.log(fullUrl); // Outputs: http://example.com/search?q=url+join"

Other packages similar to url-join

Keywords

FAQs

Package last updated on 17 Jan 2018

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc