https://github.com/raphaelhaettich/seturlparameter
Set url parameters easy
https://github.com/raphaelhaettich/seturlparameter
javascript parameter seturlparameter url
Last synced: 11 months ago
JSON representation
Set url parameters easy
- Host: GitHub
- URL: https://github.com/raphaelhaettich/seturlparameter
- Owner: RaphaelHaettich
- License: mit
- Created: 2019-01-31T16:29:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-12T13:17:26.000Z (almost 7 years ago)
- Last Synced: 2025-03-02T01:29:04.624Z (12 months ago)
- Topics: javascript, parameter, seturlparameter, url
- Language: JavaScript
- Homepage:
- Size: 37.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# setUrlParameter
## Installation
```
npm install seturlparameter
```
## Usage
```
const setUrlParameter = require('seturlparameter');
const url = 'https://www.example.com/index.html?aaa=bbb&ccc=ddd';
let key = 'eee';
const value = 'fff';
const urlWithNewParam = setUrlParameter(url, key, value);
console.log(urlWithNewParam); // result is: 'https://www.example.com/index.html?aaa=bbb&ccc=ddd&eee=fff'
key = 'aaa';
const urlWithReplacedParam = setUrlParameter(url, key, value);
console.log(urlWithReplacedParam); // result is: 'https://www.example.com/index.html?aaa=fff&ccc=ddd'
```
## Information
Based on the idee from: https://blog.bitscry.com/2018/08/17/getting-and-setting-url-parameters-with-javascript/