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

@libj/make-uri

Package Overview
Dependencies
Maintainers
0
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libj/make-uri

Uri builder

  • 1.3.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20K
increased by80.43%
Maintainers
0
Weekly downloads
 
Created
Source

Rationale

A utility function to build a valid URI.

Features

  • RFC-3986 compliant
  • clean API
  • base uri support
  • validation
  • battery of unit tests applied

makeUri() API

Import

const { makeUri } = require('@libj/make-uri');

Parameters

NameTypeExample
schemestringmakeUri({ scheme: 'http:' })
authoritystringmakeUri({ authority: 'user@some.host:333' })
authority{host: string, user?: string, port?: number }makeUri({ authority: { host: 'some.com', user: 'user', port: 333 } })
pathstringmakeUri({ path: '/foo/bar' })
path{ template: string, params: Object }makeUri({ path: { template: '/foo/:bar', params: { bar: 'my-bar' } } })
pathstring[]makeUri({ path: ['foo', 'bar'] }) => /foo/bar
queryObjectmakeUri({ query: { foo: 'bar' } }) => foo=bar
query{ $data: Object, $options: { encode: boolean } }makeUri({ query: { $data: { foo: 'bar' }, $options: { encode: true } } })
query{ $data: Object, $options: { encode: { include: string[] } } }makeUri({ query: { $data: { foo: 'bar' }, $options: { encode: { include: ['foo'] } } } })
query{ $data: Object, $options: { encode: { exclude: string[] } } }makeUri({ query: { $data: { foo: 'bar' }, $options: { exclude: { include: ['foo'] } } } })
fragmentObjectmakeUri({ path: '/foo', fragment: { foxy: 'lady' } }) => /foo#foxy=lady
fragmentSee query $data with $options above

Base uri

Basic usage

  makeUri('http://some.host/path', { query: { foo: 'bar' } })
  // => http://some.host/path?foo=bar

Append path

  makeUri('https://host.com/foo', { path: '/bar' })
  // => https://host.com/foo/bar

Keywords

FAQs

Package last updated on 21 Oct 2024

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