pure-url
TypeScript icon, indicating that this package has built-in type declarations

0.8.2 • Public • Published

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

Dependents (2)

Package Sidebar

Install

npm i pure-url

Weekly Downloads

1

Version

0.8.2

License

MIT

Unpacked Size

29.6 kB

Total Files

13

Last publish

Collaborators

  • mortenolsen