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_ssssdddddyyyycauseway-concrete-stylesgenerator-bootstrap-boilerplate-templatejeuxuijnf-accesscontrol-rnttljametkenote-config-helperkenote-deploy-kitlazy-bee-uiiii-for-vkhw9hubot-budahendo-clihendo-cli-luozheaoh5-templetelightsocks-nodejsmama-exportermarkdownalint-cli2m2m-chartjs-plugin-crosshairkooks@wecraftapps/react-native-use-keyboard@thismr/bitmindtest-core@tonysusi/vapid@vandai-nguyen/module_test@xsahxl/got@xswap/v2-core@xiwen5566/aqara-automation-switch@yplabs-ltd/react-native-detector@yak-spirit/yak-swap-uiangularvezbaawesome-react-starsarvm-bestdeveloper@happy-gastro/react-native-printer-module@hawkingnetwork/react-native-tab-view@hbglobal/react-native-actions-shortcuts3.0.0ubikud7-act2tingzi-vuepresstools_may_24twine-libtwine-libraryyangotyangzai-cliyf-sw-clivue-v3-yandex-metrikawangyaling-1awcq-vue@infinitebrahmanuniverse/nolb-url@livecycle.io/rrweb-snapshot@litedexdev/litedex-core-swapmpesa-cookiempesa-cookie-jarmy-temp-climicro-sub-climiracle-webpack-tree-shakingmfpdev-climiguelcostero-ng2-toastynative-apple-loginnative-kakao-loginnative-google-loginover-armour-masternpm_qwertynpm_one_12_34_1_npm_one_1_2_3npm_one_2_2npmtest-05041payutesting
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