Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

urltool

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

urltool

Node Module & Browser Library for parsing, formatting and serializing URLs

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
11
1000%
Maintainers
1
Weekly downloads
 
Created
Source

urltool

Node Module & Browser Library for parsing, formatting and serializing URLs

Import

In the browser, you can use UrlTool to access urltool However in node.js, you have to use require('urltool') to access urltool

Usage

Url

This class is used to parse and format URLs.

const url = new UrlTool.Url('http://example.com/path/to/file.html?param=value#hash')

.format(?template)

Format the URL.

url.format()

You can use custom templates by passing it as an argument. The default template is: {protocol}://{host}/{path}/{query}{hash}. Available properties are protocol, host, path, query, hostWithoutPort, port and hash.

.protocol

The protocol of the URL. e.g.: http

.host

The host of the URL. If the port isn't the default port for the given protocol, it will be included. e.g.: example.com, example.com:8080

.hostWithoutPort

The host of the URL ALWAYS without the port. e.g.: example.com

.port

The port of the URL. e.g.: 80

.path

The path of the URL. e.g.: /path/to/file.html

.query

The query of the URL. e.g.: ?param=value

.hash

The hash of the URL. e.g.: #hash

parseQuerystring(querystring)

Parse a querystring into an object.

UrlTool.parseQuerystring('param=value&param2=value2') // { param: 'value', param2: 'value2' }

stringifyQuerystring(query)

Stringify a query object into a querystring.

UrlTool.stringifyQuerystring({ param: 'value', param2: 'value2' }) // 'param=value&param2=value2'

Keywords

url

FAQs

Package last updated on 15 Jun 2022

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