url-parse-lax

WebJar for url-parse-lax

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

url-parse-lax
Last Version

Last Version

3.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

url-parse-lax
WebJar for url-parse-lax
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/url-parse-lax

Download url-parse-lax

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/url-parse-lax/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>url-parse-lax</artifactId>
    <version>3.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/url-parse-lax/
implementation 'org.webjars.npm:url-parse-lax:3.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/url-parse-lax/
implementation ("org.webjars.npm:url-parse-lax:3.0.0")
'org.webjars.npm:url-parse-lax:jar:3.0.0'
<dependency org="org.webjars.npm" name="url-parse-lax" rev="3.0.0">
  <artifact name="url-parse-lax" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='url-parse-lax', version='3.0.0')
)
libraryDependencies += "org.webjars.npm" % "url-parse-lax" % "3.0.0"
[org.webjars.npm/url-parse-lax "3.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : prepend-http jar [2.0.0,3)

Project Modules

There are no modules declared in this project.

url-parse-lax

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

Install

$ npm install url-parse-lax

Usage

const urlParseLax = require('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():

const 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'
}
*/

API

urlParseLax(url, options?)

url

Type: string

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

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Versions

Version
3.0.0
1.0.0