Socket
Socket
Sign inDemoInstall

extra-url

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    extra-url

A url wrapper that offers more options than the builtin one.


Version published
Maintainers
1
Install size
22.6 kB
Created

Readme

Source

extra-url

An extension of the builtin url module.

url.parse('http://user:pass@host.com:8080/p/a/t/h/file.txt?query=string%21#hash', true /* fix? -> fix half-urls */);

/*STANDARD:
┌─────────────────────────────────────────────────────────────────────────────┐
│                                    href                                     │
├──────────┬┬───────────┬─────────────────┬───────────────────────────┬───────┤
│ protocol ││   auth    │      host       │           path            │ hash  │
│          ││           ├──────────┬──────┼──────────┬────────────────┤       │
│          ││           │ hostname │ port │ pathname │     search     │       │
│          ││           │          │      │          ├─┬──────────────┤       │
│          ││           │          │      │          │ │    query     │       │
"  http:   // user:pass @ host.com : 8080   /p/a/t/h  ?  query=string   #hash "
│          ││           │          │      │          │ │              │       │
└──────────┴┴───────────┴──────────┴──────┴──────────┴─┴──────────────┴───────┘
*/ //EXTENDED:
Url {
  hrefraw: 'http://user:pass@host.com:8080/p/a/t/h/file.txt?query=string%21#hash',
  href: 'http://user:pass@host.com:8080/p/a/t/h/file.txt?query=string!#hash',
  protocolfull: 'http://',
  protocolraw: 'http:',
  protocol: 'http',
  auth: 'user:pass',
  autharr: [ 'user', 'pass' ],
  hostfull: 'user:pass@host.com:8080',
  authhost: 'user:pass@host.com',
  host: 'host.com:8080',
  hostname: 'host.com',
  port: '8080',
  pathraw: '/p/a/t/h/file.txt?query=string%21',
  path: '/p/a/t/h/file.txt?query=string!',
  pathnameraw: '/p/a/t/h/file.txt',
  pathname: '/p/a/t/h/file.txt',
  searchraw: '?query=string%21',
  search: '?query=string!',
  querystringraw: 'query=string%21',
  querystring: 'query=string!',
  queryarrrawdeep: [ [ 'query', 'string%21' ] ],
  queryarrraw: [ 'query=string%21' ],
  queryarrdeep: [ [ 'query', 'string!' ] ],
  queryarr: [ 'query=string!' ],
  queryraw: { query: 'string!' },
  query: { query: 'string!' },
  directoryraw: '/p/a/t/h',
  directory: '/p/a/t/h',
  filepureraw: '/file.txt',
  filepure: '/file.txt',
  fileraw: 'file.txt',
  file: 'file.txt',
  filenameraw: 'file',
  filename: 'file',
  extensionfull: '.txt',
  extension: 'txt',
  hashraw: '#hash',
  hash: '#hash',
  hashnameraw: 'hash',
  hashname: 'hash',
  pathobject: 
   { root: '/',
     dir: '/p/a/t/h',
     base: 'file.txt',
     ext: '.txt',
     name: 'file' },
  toString: [Function: toString],
  slashes: true,
  _revoke: [Function: revoke] }
*/

By editing one of the properties of the Url object returned by url.parse, the whole object gets rebuilt to adjust on the change!

Keywords

FAQs

Last updated on 02 Dec 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc