"Fossies" - the Fresh Open Source Software Archive

Member "node-v12.18.4-win-x64/node_modules/npm/node_modules/url-parse-lax/readme.md" (14 Feb 2020, 1709 Bytes) of package /windows/www/node-v12.18.4-win-x64.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

url-parse-lax Build Status

url.parse() with support for protocol-less URLs & IPs

Install

$ npm install --save url-parse-lax

Usage

var urlParseLax = require('url-parse-lax');

urlParseLax('sindresorhus.com');
/*
{
    protocol: null,
    slashes: true,
    auth: null,
    host: 'sindresorhus.com',
    port: null,
    hostname: 'sindresorhus.com',
    hash: null,
    search: null,
    query: null,
    pathname: '/',
    path: '/',
    href: 'http://sindresorhus.com/'
}
*/

urlParseLax('[2001:db8::]:8000');
/*
{
    protocol: null,
    slashes: true,
    auth: null,
    host: '[2001:db8::]:8000',
    port: '8000',
    hostname: '2001:db8::',
    hash: null,
    search: null,
    query: null,
    pathname: '/',
    path: '/',
    href: 'http://[2001:db8::]:8000/'
}
*/

And with the built-in url.parse():

var url = require('url');

url.parse('sindresorhus.com');
/*
{
    protocol: null,
    slashes: null,
    auth: null,
    host: null,
    port: null,
    hostname: null,
    hash: null,
    search: null,
    query: null,
    pathname: 'sindresorhus',
    path: 'sindresorhus',
    href: 'sindresorhus'
}
*/

url.parse('[2001:db8::]:8000');
/*
{
    protocol: null,
    slashes: null,
    auth: null,
    host: null,
    port: null,
    hostname: null,
    hash: null,
    search: null,
    query: null,
    pathname: '[2001:db8::]:8000',
    path: '[2001:db8::]:8000',
    href: '[2001:db8::]:8000'
}
*/

License

MIT © Sindre Sorhus