diff options
author | Minteck <contact@minteck.org> | 2022-10-18 08:59:09 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-10-18 08:59:09 +0200 |
commit | 2c4ae43e688a9873e86211ea0e7aeb9ba770dd77 (patch) | |
tree | 17848d95522dab25d3cdeb9c4a6450e2a234861f /alarm/node_modules/querystringify | |
parent | 108525534c28013cfe1897c30e4565f9893f3766 (diff) | |
download | pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.gz pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.bz2 pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.zip |
Update
Diffstat (limited to 'alarm/node_modules/querystringify')
-rw-r--r-- | alarm/node_modules/querystringify/LICENSE | 22 | ||||
-rw-r--r-- | alarm/node_modules/querystringify/README.md | 61 | ||||
-rw-r--r-- | alarm/node_modules/querystringify/index.js | 118 | ||||
-rw-r--r-- | alarm/node_modules/querystringify/package.json | 38 |
4 files changed, 239 insertions, 0 deletions
diff --git a/alarm/node_modules/querystringify/LICENSE b/alarm/node_modules/querystringify/LICENSE new file mode 100644 index 0000000..6dc9316 --- /dev/null +++ b/alarm/node_modules/querystringify/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/alarm/node_modules/querystringify/README.md b/alarm/node_modules/querystringify/README.md new file mode 100644 index 0000000..0339638 --- /dev/null +++ b/alarm/node_modules/querystringify/README.md @@ -0,0 +1,61 @@ +# querystringify + +[![Version npm](http://img.shields.io/npm/v/querystringify.svg?style=flat-square)](https://www.npmjs.com/package/querystringify)[![Build Status](http://img.shields.io/travis/unshiftio/querystringify/master.svg?style=flat-square)](https://travis-ci.org/unshiftio/querystringify)[![Dependencies](https://img.shields.io/david/unshiftio/querystringify.svg?style=flat-square)](https://david-dm.org/unshiftio/querystringify)[![Coverage Status](http://img.shields.io/coveralls/unshiftio/querystringify/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/querystringify?branch=master) + +A somewhat JSON compatible interface for query string parsing. This query string +parser is dumb, don't expect to much from it as it only wants to parse simple +query strings. If you want to parse complex, multi level and deeply nested +query strings then you should ask your self. WTF am I doing? + +## Installation + +This module is released in npm as `querystringify`. It's also compatible with +`browserify` so it can be used on the server as well as on the client. To +install it simply run the following command from your CLI: + +``` +npm install --save querystringify +``` + +## Usage + +In the following examples we assume that you've already required the library as: + +```js +'use strict'; + +var qs = require('querystringify'); +``` + +### qs.parse() + +The parse method transforms a given query string in to an object. Parameters +without values are set to empty strings. It does not care if your query string +is prefixed with a `?`, a `#`, or not prefixed. It just extracts the parts +between the `=` and `&`: + +```js +qs.parse('?foo=bar'); // { foo: 'bar' } +qs.parse('#foo=bar'); // { foo: 'bar' } +qs.parse('foo=bar'); // { foo: 'bar' } +qs.parse('foo=bar&bar=foo'); // { foo: 'bar', bar: 'foo' } +qs.parse('foo&bar=foo'); // { foo: '', bar: 'foo' } +``` + +### qs.stringify() + +This transforms a given object in to a query string. By default we return the +query string without a `?` prefix. If you want to prefix it by default simply +supply `true` as second argument. If it should be prefixed by something else +simply supply a string with the prefix value as second argument: + +```js +qs.stringify({ foo: bar }); // foo=bar +qs.stringify({ foo: bar }, true); // ?foo=bar +qs.stringify({ foo: bar }, '#'); // #foo=bar +qs.stringify({ foo: '' }, '&'); // &foo= +``` + +## License + +MIT diff --git a/alarm/node_modules/querystringify/index.js b/alarm/node_modules/querystringify/index.js new file mode 100644 index 0000000..58c9808 --- /dev/null +++ b/alarm/node_modules/querystringify/index.js @@ -0,0 +1,118 @@ +'use strict'; + +var has = Object.prototype.hasOwnProperty + , undef; + +/** + * Decode a URI encoded string. + * + * @param {String} input The URI encoded string. + * @returns {String|Null} The decoded string. + * @api private + */ +function decode(input) { + try { + return decodeURIComponent(input.replace(/\+/g, ' ')); + } catch (e) { + return null; + } +} + +/** + * Attempts to encode a given input. + * + * @param {String} input The string that needs to be encoded. + * @returns {String|Null} The encoded string. + * @api private + */ +function encode(input) { + try { + return encodeURIComponent(input); + } catch (e) { + return null; + } +} + +/** + * Simple query string parser. + * + * @param {String} query The query string that needs to be parsed. + * @returns {Object} + * @api public + */ +function querystring(query) { + var parser = /([^=?#&]+)=?([^&]*)/g + , result = {} + , part; + + while (part = parser.exec(query)) { + var key = decode(part[1]) + , value = decode(part[2]); + + // + // Prevent overriding of existing properties. This ensures that build-in + // methods like `toString` or __proto__ are not overriden by malicious + // querystrings. + // + // In the case if failed decoding, we want to omit the key/value pairs + // from the result. + // + if (key === null || value === null || key in result) continue; + result[key] = value; + } + + return result; +} + +/** + * Transform a query string to an object. + * + * @param {Object} obj Object that should be transformed. + * @param {String} prefix Optional prefix. + * @returns {String} + * @api public + */ +function querystringify(obj, prefix) { + prefix = prefix || ''; + + var pairs = [] + , value + , key; + + // + // Optionally prefix with a '?' if needed + // + if ('string' !== typeof prefix) prefix = '?'; + + for (key in obj) { + if (has.call(obj, key)) { + value = obj[key]; + + // + // Edge cases where we actually want to encode the value to an empty + // string instead of the stringified value. + // + if (!value && (value === null || value === undef || isNaN(value))) { + value = ''; + } + + key = encode(key); + value = encode(value); + + // + // If we failed to encode the strings, we should bail out as we don't + // want to add invalid strings to the query. + // + if (key === null || value === null) continue; + pairs.push(key +'='+ value); + } + } + + return pairs.length ? prefix + pairs.join('&') : ''; +} + +// +// Expose the module. +// +exports.stringify = querystringify; +exports.parse = querystring; diff --git a/alarm/node_modules/querystringify/package.json b/alarm/node_modules/querystringify/package.json new file mode 100644 index 0000000..7b25904 --- /dev/null +++ b/alarm/node_modules/querystringify/package.json @@ -0,0 +1,38 @@ +{ + "name": "querystringify", + "version": "2.2.0", + "description": "Querystringify - Small, simple but powerful query string parser.", + "main": "index.js", + "scripts": { + "test": "nyc --reporter=html --reporter=text mocha test.js", + "watch": "mocha --watch test.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/unshiftio/querystringify" + }, + "keywords": [ + "query", + "string", + "query-string", + "querystring", + "qs", + "stringify", + "parse", + "decode", + "encode" + ], + "author": "Arnout Kazemier", + "license": "MIT", + "bugs": { + "url": "https://github.com/unshiftio/querystringify/issues" + }, + "homepage": "https://github.com/unshiftio/querystringify", + "devDependencies": { + "assume": "^2.1.0", + "coveralls": "^3.1.0", + "mocha": "^8.1.1", + "nyc": "^15.1.0", + "pre-commit": "^1.2.2" + } +} |