🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

url-sub

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

url-sub

Format URLs using templates.

latest
Source
npmnpm
Version
0.12.1
Version published
Maintainers
1
Created
Source

URL Sub 🔗↔️

Format URLs for fetch requests using templates and substitution values.

usage

import * as UrlSub from "url-sub"

UrlSub.formatUrl("https://api.example.com", "/user/:username/bio", {
  username: "jake",
  exclude_sensitive: true
})

// https://api.example.com/user/jake/bio?exclude_sensitive=true

// If you'd like to use options.
UrlSub.formatUrlWithOptions(
  "https://api.example.com/",
  "/user",
  {
    normally_encoded: "https://dont-encode-me.com",
  },
  { encode: false }
),

// "https://api.example.com/user?normally_encoded=https://dont-encode-me.com"

options

  • encodeParams: boolean - don't encode query params.

Keywords

url

FAQs

Package last updated on 19 Aug 2022

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