@lbzg/url-parsedeprecated

Js url parsing library.

Usage no npm install needed!

<script type="module">
  import lbzgUrlParse from 'https://cdn.skypack.dev/@lbzg/url-parse';
</script>

README

Javascript library for parsing URLs.
w/ type declarations

Installation & Usage

npm i @lbzg/url-parse
const { purl } = require('@lbzg/url-parse')

const p1 = purl('https://igor@xyz.com:3337/part1/asdf/bubble.html?name=qwe#overview')

# p1.scheme = 'https',
# p1.authority = 'igor@xyz.com:3337',
# p1.user = 'igor',
# p1.host = 'xyz.com',
# p1.port = '3337',
# p1.path = '/part1/asdf/bubble.html',
# p1.pathArray = [ 'part1', 'asdf', 'bubble.html' ],
# p1.query = 'name=qwe',
# p1.queryObject = { name: 'qwe' },
# p1.fragment = 'overview'

const p2 = purl('/part1/asdf/bubble.html?name=qwe')

# p2.scheme = '',
# p2.authority = '',
# p2.user = '',
# p2.host = '',
# p2.port = '',
# p2.path = '/part1/asdf/bubble.html',
# p2.pathArray = [ 'part1', 'asdf', 'bubble.html' ],
# p2.query = 'name=qwe',
# p2.queryObject = { name: 'qwe' },
# p2.fragment = ''

Prototype

purl(url) - returns parsed object

parsed object properties:
scheme, authority, user, host, port, path, pathArray, query, queryObject, fragment

References

lbzg/validate