Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alextes/url-sub
Format a URLs using a templates.
https://github.com/alextes/url-sub
Last synced: 2 days ago
JSON representation
Format a URLs using a templates.
- Host: GitHub
- URL: https://github.com/alextes/url-sub
- Owner: alextes
- Created: 2022-02-15T11:01:22.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-19T19:03:10.000Z (over 2 years ago)
- Last Synced: 2025-01-01T10:17:55.559Z (6 days ago)
- Language: TypeScript
- Homepage:
- Size: 116 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# URL Sub 🔗↔️
Format URLs for fetch requests using templates and substitution values.
## usage
```ts
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.