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

url-query-builder

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

url-query-builder - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

102

index.js

@@ -1,57 +0,55 @@

function UrlQueryBuilder = function (url) {
this.url = url || "";
this.query = {};
};
module.exports = function UrlQueryBuilder = function (url) {
this.url = url || "";
this.query = {};
/**
* Get a current url with queries
*/
UrlQueryBuilder.prototype.getUrl = function() {
var url = this.url + "?";
for(var name in this.query) {
url += name + "=" + this.query[name] + "&";
}
return url;
};
/**
* Get a current url with queries
*/
UrlQueryBuilder.prototype.getUrl = function() {
var url = this.url + "?";
for(var name in this.query) {
url += name + "=" + this.query[name] + "&";
}
return url;
};
/**
* Delete query by name
* @param {string} name, query that will be deleted
*/
UrlQueryBuilder.prototype.delete = function(name) {
if(!this.query[name])
throw new Error("Can't delete. Query: '" + name + "' not exists");
delete this.query[name];
return this;
};
/**
* Delete query by name
* @param {string} name, query that will be deleted
*/
UrlQueryBuilder.prototype.delete = function(name) {
if(!this.query[name])
throw new Error("Can't delete. Query: '" + name + "' not exists");
delete this.query[name];
return this;
};
/**
* Change query by name
* @param {string} name, query what will be changed
* @param {string|number} value, new value for query
*/
UrlQueryBuilder.prototype.change = function(name, value) {
if(!this.query[name])
throw new Error("Can't change. Query: '" + name + "' not exists");
this.query[name] = value.toString();
return this;
};
/**
* Change query by name
* @param {string} name, query what will be changed
* @param {string|number} value, new value for query
*/
UrlQueryBuilder.prototype.change = function(name, value) {
if(!this.query[name])
throw new Error("Can't change. Query: '" + name + "' not exists");
this.query[name] = value.toString();
return this;
};
/**
* Add new query
* @param name, name of new query
* @param value, value for new query
*/
UrlQueryBuilder.prototype.add = function(name, value) {
if(this.query[name])
throw new Error("Can't add. Query: '" + name + "' already exists");
this.query[name] = value.toString();
return this;
};
/**
* Add new query
* @param {string} name, name of new query
* @param {string|number} value, value for new query
*/
UrlQueryBuilder.prototype.add = function(name, value) {
if(this.query[name])
throw new Error("Can't add. Query: '" + name + "' already exists");
this.query[name] = value.toString();
return this;
};
module.exports = UrlQueryBuilder;
};
{
"name": "url-query-builder",
"version": "1.0.1",
"version": "1.0.2",
"description": "Simple add/change/delete url query",

@@ -5,0 +5,0 @@ "main": "index.js",

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