Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decompose-url

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decompose-url

A quick and easy URL decomposer for breaking URLs into their constituent parts.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

decompose-url

NPM version Bower version Build Status Coverage Status

A quick and easy URL decomposer for breaking URLs into their constituent parts.

Install

NPM
$ npm install decompose-url
Bower
bower install --save decompose-url

Node.js

var decomposeUrl = require('decompose-url')

var decomposedUrl = decomposeUrl('http://test.example.com:8000/one/two/three?value=abc&value2=123#david-rules');
// `decomposedUrl` now contains the decomposed values from the url that was passed. See [Url](#url-model) for the structure.

var decomposedUrlWithParams = decomposeUrl('http://test.example.com:8000/one/two/three?value=abc&value2=123#david-rules', '/:value1/:value2/:value3');
// `decomposedUrlWithParams` now contains the decomposed values from the url that was passed and now decomposedUrlWithParams.params is populated with a map of the path parameters that were passed and their values. See [Url](#url-model) for the structure.

Browser

<script type="text/javascript" src="decompose-url.js"></script>
<script type="text/javascript">
var decomposedUrl = decomposeUrl('http://test.example.com:8000/one/two/three?value=abc&value2=123#david-rules');
// `decomposedUrl` now contains the decomposed values from the url that was passed. See [Url](#url-model) for the structure.

var decomposedUrlWithParams = decomposeUrl('http://test.example.com:8000/one/two/three?value=abc&value2=123#david-rules', '/:value1/:value2/:value3');
// `decomposedUrlWithParams` now contains the decomposed values from the url that was passed and now decomposedUrlWithParams.params is populated with a map of the path parameters that were passed and their values. See [Url](#url-model) for the structure.
</script>

Url Model

  • protocol - The protocol in the URL, null if none. (eg. 'http')
  • username - The username in the URL, null if none. (eg. 'david')
  • password - The password in the URL, null if none. (eg. 'l33t5auce#!')
  • hostname - The full hostname in the URL, null if none. (eg. 'mail.google.com')
  • host - An array of the domain names in the URL, null if none. (eg. ['mail', 'google'])
  • tld - The top level domain in the URL, null if none. (eg. 'com')
  • port - The port in the URL. Default: 80, if there is a host (eg. '80')
  • path - An array of the path parts in the URL, null if none. (eg. ['mail', 'u', '0'])
  • params - A map of the path parameters (only populated if a template was passed) in the URL, null if no template was passed. (eg. { 'user' : 0 })
  • search - The full search part in the URL, null if none. (eg. 'ui=1&pli=1')
  • query - A map of the query parameters in the URL, null if none. (eg. { 'ui': '1', 'pli': '1' })
  • hash - The full hash in the URL, null if none. (eg. 'inbox')
  • hash - The original URL that was decomposed (eg. 'http://david:l33t5auce#!@mail.google.com/mail/u/0?ui=2&pli=1#inbox')

License

MIT

Keywords

FAQs

Package last updated on 02 Aug 2014

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