Socket
Socket
Sign inDemoInstall

browser-url

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    browser-url

URL utility for browser


Version published
Weekly downloads
357
increased by36.26%
Maintainers
1
Install size
18.1 kB
Created
Weekly downloads
 

Readme

Source

Url

URL utility for browser.

See x-url for cross-platform URL utility.

// use current location
var url = new Url();
console.log('current location', url);

url = new Url('http://www.example.com/foo/bar?a=1&b=2#p2');
console.log('http://www.example.com/foo/bar?a=1&b=2#p2', url);
console.log('href:', url.href);
console.log('protocol: ', url.protocol);
console.log('host:', url.host);
console.log('hostname:', url.hostname);
console.log('port:', url.port);
console.log('pathname:', url.pathname);
console.log('search:', url.search);
console.log('hash:', url.hash);
console.log('query:', url.query);

url.query.foo = 'bar';
console.log(url.href);

console.log(url.addQuery('one', 1).addQuery({
  two: 2,
  foo: 3
}).removeQuery('a', 'b').href);

console.log(url.setQuery({
  foo: 1,
  bar: 2
}).set('hash', '#p1').href);

console.log(url.set('search', '?foo=2&bar=3').query);
console.log(url.sortQuery().href);

License

MIT

Keywords

FAQs

Last updated on 18 Jul 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