1.3.12 • Published 9 months ago

@libj/make-uri v1.3.12

Weekly downloads
185
License
ISC
Repository
github
Last release
9 months ago

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
1.3.12

9 months ago

1.3.11

10 months ago

1.3.10

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.13

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago