readme.md
1# url-parse-lax [![Build Status](https://travis-ci.org/sindresorhus/url-parse-lax.svg?branch=master)](https://travis-ci.org/sindresorhus/url-parse-lax)
2
3> [`url.parse()`](https://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost) with support for protocol-less URLs & IPs
4
5
6## Install
7
8```
9$ npm install --save url-parse-lax
10```
11
12
13## Usage
14
15```js
16var urlParseLax = require('url-parse-lax');
17
18urlParseLax('sindresorhus.com');
19/*
20{
21 protocol: null,
22 slashes: true,
23 auth: null,
24 host: 'sindresorhus.com',
25 port: null,
26 hostname: 'sindresorhus.com',
27 hash: null,
28 search: null,
29 query: null,
30 pathname: '/',
31 path: '/',
32 href: 'http://sindresorhus.com/'
33}
34*/
35
36urlParseLax('[2001:db8::]:8000');
37/*
38{
39 protocol: null,
40 slashes: true,
41 auth: null,
42 host: '[2001:db8::]:8000',
43 port: '8000',
44 hostname: '2001:db8::',
45 hash: null,
46 search: null,
47 query: null,
48 pathname: '/',
49 path: '/',
50 href: 'http://[2001:db8::]:8000/'
51}
52*/
53```
54
55And with the built-in `url.parse()`:
56
57```js
58var url = require('url');
59
60url.parse('sindresorhus.com');
61/*
62{
63 protocol: null,
64 slashes: null,
65 auth: null,
66 host: null,
67 port: null,
68 hostname: null,
69 hash: null,
70 search: null,
71 query: null,
72 pathname: 'sindresorhus',
73 path: 'sindresorhus',
74 href: 'sindresorhus'
75}
76*/
77
78url.parse('[2001:db8::]:8000');
79/*
80{
81 protocol: null,
82 slashes: null,
83 auth: null,
84 host: null,
85 port: null,
86 hostname: null,
87 hash: null,
88 search: null,
89 query: null,
90 pathname: '[2001:db8::]:8000',
91 path: '[2001:db8::]:8000',
92 href: '[2001:db8::]:8000'
93}
94*/
95```
96
97
98## License
99
100MIT © [Sindre Sorhus](http://sindresorhus.com)
101