0.8.2 • Published 6 years ago

pure-url v0.8.2

Weekly downloads
247
License
MIT
Repository
-
Last release
6 years ago

Pure-URL

A really lightweight (≈81 lines of TypeScript, ≈500b gzipped js, with es5 support) url parser, which works both in node and on the web and without any dependencies

Install

npm install --save pure-url or yarn add pure-url

Usage

Parse the query using const url = PureUrl.parse('http://www.example.com'), to get a new URL object. All properties are mutable and can be used to update the url

Properties

  • schema: the schema of the url, for instance http for http://example.com or example for example://demo
  • hostname: the hostname of the url, for instance www.example.com for http://www.example.com
  • path: the path of the url as a string, for instance /foo/bar for http://www.example.com/foo/bar
  • pathSegments: the path of the url as an array, for instance ['foo','bar'] for http://www.example.com/foo/bar
  • queryString: the query of the url as a string, for instance ?hello=world for http://www.example.com?hello=world
  • query: the query of the url as an object, for instance { hello: 'world' } for http://www.example.com?hello=world

Methods

  • toString: takes the url, including all changes, and creates a url string