@ultraq/url-utils

0.4.0 • Public • Published

url-utils

Build Status Coverage Status npm Bundlephobia minified size

A collection of utilities for working with URLs.

Installation

Via npm:

npm install @ultraq/url-utils

API

join(...urlParts)

Concatenate several URL parts into a single string, inserting forward slashes between each part and taking care not to double-slash any parts. Useful for when the URL parts aren't known to include their respective slashes or not.

The first URL will retain any leading slash, and the last URL will retain any trailing slash.

  • urlParts: argument list of URL parts to combine

objectToSearchString(object)

Convert an object to a URL query parameter string, minus a leading ?.

  • object: Object whose key/value pairs are converted to key=value URL parameters, joined by &s.

searchStringToObject(searchString)

Convert URL query parameters to an object.

  • searchString: String where key=value is converted to object keys/values, pairs separated by &s and ignoring any leading ?.

Package Sidebar

Install

npm i @ultraq/url-utils

Weekly Downloads

0

Version

0.4.0

License

Apache-2.0

Unpacked Size

32.7 kB

Total Files

10

Last publish

Collaborators

  • ultraq