0.8.2 • Published 6 years ago
pure-url v0.8.2
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
forhttp://example.com
orexample
forexample://demo
- hostname: the hostname of the url, for instance
www.example.com
forhttp://www.example.com
- path: the path of the url as a string, for instance
/foo/bar
forhttp://www.example.com/foo/bar
- pathSegments: the path of the url as an array, for instance
['foo','bar']
forhttp://www.example.com/foo/bar
- queryString: the query of the url as a string, for instance
?hello=world
forhttp://www.example.com?hello=world
- query: the query of the url as an object, for instance
{ hello: 'world' }
forhttp://www.example.com?hello=world
Methods
- toString: takes the url, including all changes, and creates a url string