Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

seturlparameter

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seturlparameter - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

yarn.lock

10

package.json
{
"name": "seturlparameter",
"version": "1.0.0",
"version": "1.0.1",
"description": "set an url parameter",
"main": "setUrlParameter.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "google-closure-compiler --js=setUrlParameter.js --js_output_file=setUrlParameter.min.js"
},
"author": "Raphael Hättich",
"license": "MIT"
"license": "MIT",
"devDependencies": {
"google-closure-compiler": "^20190121.0.0"
}
}
# 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'
```

@@ -15,3 +15,3 @@ const setParam = (urlQueryString, newParam, encodedValue, encodedKey) => {

return urlQueryString + '&' + newParam;
}
};

@@ -38,4 +38,4 @@ const setUrlParameter = (url, key, value) => {

return baseUrl + params;
}
};
module.exports = setUrlParameter;

@@ -1,1 +0,1 @@

var setParam=function(a,b,c,d){var e=new RegExp("([?&])"+d+"[^&]*");d=new RegExp("([?&])"+d+"=[^&;]+[&;]?");return"undefined"===typeof c||null===c||""===c?a.replace(d,"$1").replace(/[&;]$/,""):null!==a.match(e)?a.replace(e,"$1"+b):""==a?"?"+b:a+"&"+b},setUrlParameter=function(a,b,c){b=encodeURIComponent(b);var d=encodeURIComponent(c);c=a.split("?")[0];var e=b+"="+d;a=(a=void 0==a.split("?")[1]?"":"?"+a.split("?")[1])?setParam(a,e,d,b):"?"+e;return"?"===a?"":c+a};module.exports=setUrlParameter;
var setParam=function(a,b,c,d){var e=new RegExp("([?&])"+d+"[^&]*");d=new RegExp("([?&])"+d+"=[^&;]+[&;]?");return"undefined"===typeof c||null===c||""===c?a.replace(d,"$1").replace(/[&;]$/,""):null!==a.match(e)?a.replace(e,"$1"+b):""==a?"?"+b:a+"&"+b},setUrlParameter=function(a,b,c){b=encodeURIComponent(b);var d=encodeURIComponent(c);c=a.split("?")[0];var e=b+"="+d;a=(a=void 0==a.split("?")[1]?"":"?"+a.split("?")[1])?setParam(a,e,d,b):"?"+e;return"?"===a?"":c+a};module.exports=setUrlParameter;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc