urlparser-simple

1.0.3 • Public • Published

urlparser

dependencies Status npm version

Parses HTTP(S) and (S)FTP URLs. Not sure why I bothered crafting my own REGEX to try and handle nearly all URL conditions but I did.

Usage

import { parseUri } from '../urlparser'
console.log(parseUri('https://user:password@www.google.com:8000/test/url?param=blah&blah[]=test#hash.tag'))

Returns:

{
    "authority": "user:password",
    "fragment": "hash.tag",
    "host": "www.google.com",
    "path": "test/url",
    "port": 8000,
    "query": "param=blah&blah[]=test#arr",
    "request": "https://user:password@www.google.com:8000/test/url?param=blah&blah[]=test#hash.tag",
    "scheme": "https",
    "tld": "com",
    "valid": true,
}

parseUri() accepts a second parameter "strict" (boolean) which enforces the standard ASCII character set for URLs if set to true.

Bugs

Feel free to report bugs :)

Package Sidebar

Install

npm i urlparser-simple

Weekly Downloads

3

Version

1.0.3

License

MIT

Unpacked Size

24.1 kB

Total Files

9

Last publish

Collaborators

  • moxyscript