Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsuri

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsuri

Uri and query string manipulation

  • 1.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
74K
decreased by-42.68%
Maintainers
1
Weekly downloads
 
Created

What is jsuri?

The jsuri npm package is a lightweight library for working with URIs in JavaScript. It provides a simple API for parsing, manipulating, and building URIs.

What are jsuri's main functionalities?

Parsing URIs

This feature allows you to parse a URI and extract its components such as protocol, host, port, path, query, and fragment.

const Uri = require('jsuri');
const uri = new Uri('http://user:pass@www.example.com:8080/path?query=string#fragment');
console.log(uri.protocol()); // 'http'
console.log(uri.host()); // 'www.example.com'
console.log(uri.port()); // '8080'
console.log(uri.path()); // '/path'
console.log(uri.query()); // 'query=string'
console.log(uri.fragment()); // 'fragment'

Manipulating URIs

This feature allows you to manipulate different parts of a URI, such as changing the protocol, host, port, path, query parameters, and fragment.

const Uri = require('jsuri');
let uri = new Uri('http://www.example.com');
uri.setProtocol('https');
uri.setHost('example.org');
uri.setPort('3000');
uri.setPath('/newpath');
uri.setQuery('key', 'value');
uri.setFragment('newfragment');
console.log(uri.toString()); // 'https://example.org:3000/newpath?key=value#newfragment'

Building URIs

This feature allows you to build a URI from scratch by setting its components and adding query parameters.

const Uri = require('jsuri');
let uri = new Uri();
uri.setProtocol('https');
uri.setHost('www.example.com');
uri.setPath('/path');
uri.addQueryParam('key1', 'value1');
uri.addQueryParam('key2', 'value2');
console.log(uri.toString()); // 'https://www.example.com/path?key1=value1&key2=value2'

Other packages similar to jsuri

Keywords

FAQs

Package last updated on 24 Sep 2012

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc