Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/enzoborgfrantz/url-shaper
https://github.com/enzoborgfrantz/url-shaper
babel es6 jest rollup
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/enzoborgfrantz/url-shaper
- Owner: enzoborgfrantz
- License: mit
- Created: 2017-09-03T16:18:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-08T16:05:07.000Z (over 7 years ago)
- Last Synced: 2025-01-15T17:34:03.899Z (11 days ago)
- Topics: babel, es6, jest, rollup
- Language: JavaScript
- Size: 161 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# url-shaper
A library for simplifying url construction## Description
This module exports a function which expects two parameters:
1. A string containing the url path
2. An object containing query parametersOutputs a url made up of the concatenated path and the query parameters.
## Notes:
> If the path provided does not contain a forward slash after the domain, this is automatically resolved
> Any keys or values in the query parameters object equal to: null, 'null', undefined, 'undefined' are ommitted.
## Example
```javascript
import urlShaper from 'url-shaper';const path = 'http://www.test.com'; // the slash '/' after .com be automatically resolved
const queryParameters = {
name: 'John',
age: 16,
registered: true,
null: 1, // will be ommitted
undefined: 2, // will be ommitted
city: null, // will be ommitted
country: undefined, // will be ommitted
};const url = urlShaper(path, queryParameters);
// url: 'http://www.test.com/?name=John&age=16®istered=true'
```### [Code](https://github.com/enzoborgfrantz/url-shaper/blob/master/src/urlShaper.js)
### [Tests](https://github.com/enzoborgfrantz/url-shaper/blob/master/test/urlShaper.test.js)