Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattiadevivo/build-url
A super simple url builder
https://github.com/mattiadevivo/build-url
Last synced: about 1 month ago
JSON representation
A super simple url builder
- Host: GitHub
- URL: https://github.com/mattiadevivo/build-url
- Owner: mattiadevivo
- License: mit
- Created: 2022-11-10T08:01:12.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-12-15T15:48:08.000Z (almost 2 years ago)
- Last Synced: 2024-04-29T14:22:29.487Z (7 months ago)
- Language: TypeScript
- Size: 144 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# @mattiadevivo/build-url
[![Publish to npmjs](https://github.com/mattiadevivo/build-url/actions/workflows/npm-publish.yml/badge.svg?branch=master)](https://github.com/mattiadevivo/build-url/actions/workflows/npm-publish.yml)
A super simple and zero-dependency url builder.
You're coming from `build-url` package but it's been deprecated and lacks support for **ESM** and **TS**?
This new build-url comes with the intention of substituting it with **zero dependencies**, let's help me to make it a better version (see [CONTRIBUTING.md](./CONTRIBUTING.md))!## Installation
Install it with npm:
```bash
npm install @mattiadevivo/build-url --save
```No need of `@types` package since it has built-in support for TypeScript.
## Usage
- No need to manage ending *basePath* ending with `/` or *path* starting with `/`, the function will manage it.
- No need to worry about double `/`, *build-url* function will remove them (except for the ones after the protocol i.e. `https://`).
Usage in TypeScript/ES6:
```ts
import {buildUrl} from "@mattiadevivo/build-url";const result = buildUrl("http://localhost:8080", {
path: "api/hello/",
queryParams: {
a: 1,
b: 2,
},
});
// This will produce http://localhost:8080/api/hello/?a=1&b=2
```There is no support for commonjs modules right now, but it will be introduced later!
## Changelog
See [CHANGELOG.md](./CHANGELOG.md)
## Want to contribute?
This project is under a MIT license.
See [CONTRIBUTING.md](./CONTRIBUTING.md)