JSPM

@economia/compose-url

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q41181F
  • License ISC

Compose url from express url pattern

Package Exports

  • @economia/compose-url

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@economia/compose-url) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Compose url

Replaces Express URL pattern with regular URL.

Install

npm install @economia/compose-url --save

ES6 import

import { composeURL } from '@economia/compose-url'

Common js import

const { composeURL } = require('@economia/compose-url')

Example:

const pattern = '/users/:id'
const params = { id: 42 }

const URL =  composeURL(pattern, params)
// /users/42
const pattern = '/users/:id'
const params = {}

const URL = composeURL(pattern, params)
// error

Optional parameters end with "?" and can be omitted

const pattern = '/users/:id?'
const params = { id: 42 }

const URL = composeURL(pattern, params)
// /users/42
const pattern = '/users/:id?'
const params = {}

const URL = composeURL(pattern, params)
// /users