5.0.0 • Published 4 years ago

url-parse-lax v5.0.0

Weekly downloads
15,177,710
License
MIT
Repository
github
Last release
4 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-3023test-gotweb-elements-iconsweb-component-tester-bundlewebchewhatsconcteapackage-tatespoorman297spotify-local-controltest-public-provision-camera-plugin-scan-facesvite_vue3_ts_ssssdddddyyyy@con-test/react-native-concent-common@corelmax/react-native-my2c2p-sdk@borealisswap/borealis-swap-lib@rstacruz/pnpm@payvo/sdkcauseway-concrete-stylesgenerator-bootstrap-boilerplate-templatejeuxuijnf-accesscontrol-rnttljametkenote-config-helperkenote-deploy-kitlazy-bee-ui3.0.0ubikud7-act2tingzi-vuepresstools_may_24twine-libtwine-library@apardellass/react-native-audio-stream@arkecosystem/platform-sdk-avax@arkecosystem/platform-sdk-btc-indexer@arkecosystem/platform-sdk-btc-server@asiz33/smartblok-vendure-plugin@ardenthq/sdk@autotelic/ietf-hmac-signatures@afria/afria-libraries@bee-icons/qwik@bkrmadtya/sorting-steps@chiaraani/bouncing-ball@chakra-swap/core@cleveradssolutions/cas.cordova.ironsource@cleveradssolutions/cas.cordova.kidoz@cleveradssolutions/cas.cordova.mintegral@cleveradssolutions/cas.cordova.mytarget@cleveradssolutions/cas.cordova.optimal@cleveradssolutions/cas.cordova.pangle@cleveradssolutions/cas.cordova.superawesome@cleveradssolutions/cas.cordova.tapjoy@cleveradssolutions/cas.cordova.unity@cleveradssolutions/cas.cordova.vungle@cleveradssolutions/cas.cordova.yandex@cleveradssolutions/cas.cordova.adcolony@cleveradssolutions/cas.cordova.admob@cleveradssolutions/cas.cordova.applovin@cleveradssolutions/cas.cordova.facebook@cleveradssolutions/cas.cordova.families@cleveradssolutions/cas.cordova.fyber@cleveradssolutions/cas.cordova.inmobi@bonsaiswap-lib/lib@bonsaiswapv3/core@bonsaiswapv3/deployyangotyangzai-cliyf-sw-clivue-v3-yandex-metrikawangyaling-1awcq-vue@felipesimmi/react-native-datalogic-module@hawkingnetwork/react-native-tab-view@hbglobal/react-native-actions-shortcuts@geeky-apo/react-native-advanced-clipboard@eliteswap/v2-core@innoswap/core@innodata/vue-v3-ya-metrika@infinitebrahmanuniverse/nolb-url
5.0.0

4 years ago

4.0.0

6 years ago

3.0.0

8 years ago

2.0.0

8 years ago

1.0.0

10 years ago