5.0.0 • Published 3 years ago

url-parse-lax v5.0.0

Weekly downloads
15,177,710
License
MIT
Repository
github
Last release
3 years ago

url-parse-lax

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

Install

$ npm install url-parse-lax

Usage

import urlParseLax from 'url-parse-lax';

urlParseLax('sindresorhus.com');
/*
{
	protocol: 'https:',
	slashes: true,
	auth: null,
	host: 'sindresorhus.com',
	port: null,
	hostname: 'sindresorhus.com',
	hash: null,
	search: null,
	query: null,
	pathname: '/',
	path: '/',
	href: 'https://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():

import url from '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'
}
*/

API

urlParseLax(url, options?)

url

Type: string

The URL to parse.

options

Type: object

https

Type: boolean\ Default: true

Prepend https:// instead of http:// to protocol-less URLs.

Related

  • url-format-lax - Lax url.format() that formats a hostname and port into IPv6-compatible socket form of hostname:port

archetype-libraryreact-native-bluetooth2killi8n-react-native-fast-imagecad-cli@cashremit/cr-streamline-iconsairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@ntt_app/react-native-custom-notificationdiscord-music-botsreact-native-covid-sdk@saeon/quick-formmysql-formatreact-native-printer-brotherscogoportutilsdyx-reacttalent-to-vite-clione-indexunblock-block-save-variables@prodam/prodam-types@everything-registry/sub-chunk-3023doneselectron-pdf-window-autoelectron-epos-printerelectron-auto-print-pdfdrift-npmds-parse-url3.0.0@cleveradssolutions/cas.cordova.facebookreact-native-badge-controlreact-native-biometric-authenticate@phong95/react-native-multiple-image-picker@serverless-devs/gotreact-native-contact-listreact-native-dsphoto-module@olympfin/olymp-swap-libreact-native-cplusreact-native-create-video-thumbnailreact-native-bubble-chartreact-native-is7react-native-jsi-device-inforeact-native-kakao-mapsreact-native-flyyh5-templete@samwinslow/edgedbreac-native-arun-ramya-testgdphpttgenerator-liuhuijun-vuegotv7.1.0@saad27/react-native-bottom-tab-tourgot-litegot_with_strict_duplexer3_versiongot-tmpover-armour-masteretheral-clipipetreeprivacy-gradeyangotyangzai-clireact-native-plugpag-wrapperreact-native-responsive-sizereact-native-modal-progress-barreact-native-sayhello-modulehendo-clihendo-cli-luozheaoreact-native-test-module-hhhreact-native-teads-sdk-modulereact-native-syan-photo-pickerreact-native-transtracker-libraryhubot-budareact-native-ytximkitreact-native-payu-payment-testingreact-native-pulsator-nativehw9web-component-tester-bundlewcq-vueweb-elements-iconswangyaling-1afirst-app-lyfucipayutestingfhir2webchewhatsconcgenerator-bootstrap-boilerplate-templatepsql-streamgix-npm-serverraact-native-arunramya151pixiu-swap-corepixiuswap-libs-sdkpolen-web-components-reactfugot@tonysusi/vapid@thismr/bitmindtest-corereact-native-arun-ramya-testreact-native-arunjeyam1987react-native-arunmeena1987react-native-arunramya151react-picky-with-clear
5.0.0

3 years ago

4.0.0

5 years ago

3.0.0

6 years ago

2.0.0

7 years ago

1.0.0

9 years ago