pax_global_header00006660000000000000000000000064140125035070014507gustar00rootroot0000000000000052 comment=2875f763cc23add72c7c848e0c5779fa3a08516e querystring-0.2.1/000077500000000000000000000000001401250350700141035ustar00rootroot00000000000000querystring-0.2.1/.github/000077500000000000000000000000001401250350700154435ustar00rootroot00000000000000querystring-0.2.1/.github/workflows/000077500000000000000000000000001401250350700175005ustar00rootroot00000000000000querystring-0.2.1/.github/workflows/ci-legacy.yml000066400000000000000000000011621401250350700220600ustar00rootroot00000000000000name: LEGACY on: push jobs: test: name: Test on Node ${{ matrix.node }} and ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: node: ["0.8", "0.10", "0.12", "4", "6", "8"] os: [ubuntu-16.04] steps: - uses: actions/checkout@v2 - name: Setup node ${{ matrix.node }} uses: dcodeIO/setup-node-nvm@master with: node-version: ${{ matrix.node }} - name: Disabling Strict SSL run: npm conf set strict-ssl false - name: Installing Dependencies run: npm install - name: Running Tests run: npm test querystring-0.2.1/.github/workflows/ci.yml000066400000000000000000000010251401250350700206140ustar00rootroot00000000000000name: CI on: push jobs: test: name: Test on Node ${{ matrix.node }} and ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: node: ["10.x", "12.x", "14.x"] os: [ubuntu-latest, windows-latest, macOS-latest] steps: - uses: actions/checkout@v2 - name: Setup node uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} - name: Installing Dependencies run: npm install - name: Running Tests run: npm test querystring-0.2.1/.github/workflows/release.yml000066400000000000000000000010741401250350700216450ustar00rootroot00000000000000name: RELEASE on: push: tags: - v[0-9]+.[0-9]+.[0-9]+ jobs: test: name: Release runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Setup node uses: actions/setup-node@v2 with: node-version: 14.x registry-url: https://registry.npmjs.org - name: Installing Dependencies run: npm install - name: Running Tests run: npm test - name: Publishing to NPM env: NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} run: npm publish querystring-0.2.1/.gitignore000066400000000000000000000000371401250350700160730ustar00rootroot00000000000000node_modules package-lock.json querystring-0.2.1/.npmignore000066400000000000000000000000151401250350700160760ustar00rootroot00000000000000test .github querystring-0.2.1/CHANGELOG.md000066400000000000000000000013361401250350700157170ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. ### [0.2.1](https://github.com/Gozala/querystring/compare/v0.2.0...v0.2.1) (2021-02-15) _Maintanance update_ ## [0.2.0] - 2013-02-21 ### Changed - Refactor into function per-module idiomatic style. - Improved test coverage. ## [0.1.0] - 2011-12-13 ### Changed - Minor project reorganization ## [0.0.3] - 2011-04-16 ### Added - Support for AMD module loaders ## [0.0.2] - 2011-04-16 ### Changed - Ported unit tests ### Removed - Removed functionality that depended on Buffers ## [0.0.1] - 2011-04-15 ### Added - Initial release querystring-0.2.1/LICENSE000066400000000000000000000020431401250350700151070ustar00rootroot00000000000000Copyright 2012 Irakli Gozalishvili 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. querystring-0.2.1/README.md000066400000000000000000000011541401250350700153630ustar00rootroot00000000000000# querystring [![NPM](https://img.shields.io/npm/v/querystring.svg)](https://npm.im/querystring) [![gzip](https://badgen.net/bundlephobia/minzip/querystring@latest)](https://bundlephobia.com/result?p=querystring@latest) Node's querystring module for all engines. _If you want to help with evolution of this package, please see https://github.com/Gozala/querystring/issues/20 PR's welcome!_ ## 🔧 Install ```sh npm i querystring ``` ## 📖 Documentation Refer to [Node's documentation for `querystring`](https://nodejs.org/api/querystring.html). ## 📜 License MIT © [Gozala](https://github.com/Gozala) querystring-0.2.1/decode.d.ts000066400000000000000000000013531401250350700161220ustar00rootroot00000000000000/** * parses a URL query string into a collection of key and value pairs * * @param qs The URL query string to parse * @param sep The substring used to delimit key and value pairs in the query string * @param eq The substring used to delimit keys and values in the query string * @param options.decodeURIComponent The function to use when decoding percent-encoded characters in the query string * @param options.maxKeys Specifies the maximum number of keys to parse. Specify 0 to remove key counting limitations default 1000 */ export type decodeFuncType = ( qs?: string, sep?: string, eq?: string, options?: { decodeURIComponent?: Function; maxKeys?: number; } ) => Record; export default decodeFuncType; querystring-0.2.1/decode.js000066400000000000000000000045371401250350700156750ustar00rootroot00000000000000// Copyright Joyent, Inc. and other Node 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. 'use strict'; // If obj.hasOwnProperty has been overridden, then calling // obj.hasOwnProperty(prop) will break. // See: https://github.com/joyent/node/issues/1707 function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } module.exports = function(qs, sep, eq, options) { sep = sep || '&'; eq = eq || '='; var obj = {}; if (typeof qs !== 'string' || qs.length === 0) { return obj; } var regexp = /\+/g; qs = qs.split(sep); var maxKeys = 1000; if (options && typeof options.maxKeys === 'number') { maxKeys = options.maxKeys; } var len = qs.length; // maxKeys <= 0 means that we should not limit keys count if (maxKeys > 0 && len > maxKeys) { len = maxKeys; } for (var i = 0; i < len; ++i) { var x = qs[i].replace(regexp, '%20'), idx = x.indexOf(eq), kstr, vstr, k, v; if (idx >= 0) { kstr = x.substr(0, idx); vstr = x.substr(idx + 1); } else { kstr = x; vstr = ''; } k = decodeURIComponent(kstr); v = decodeURIComponent(vstr); if (!hasOwnProperty(obj, k)) { obj[k] = v; } else if (Array.isArray(obj[k])) { obj[k].push(v); } else { obj[k] = [obj[k], v]; } } return obj; }; querystring-0.2.1/encode.d.ts000066400000000000000000000010361401250350700161320ustar00rootroot00000000000000/** * It serializes passed object into string * The numeric values must be finite. * Any other input values will be coerced to empty strings. * * @param obj The object to serialize into a URL query string * @param sep The substring used to delimit key and value pairs in the query string * @param eq The substring used to delimit keys and values in the query string * @param name */ export type encodeFuncType = ( obj?: Record, sep?: string, eq?: string, name?: any ) => string; export default encodeFuncType; querystring-0.2.1/encode.js000066400000000000000000000040721401250350700157010ustar00rootroot00000000000000// Copyright Joyent, Inc. and other Node 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. 'use strict'; var stringifyPrimitive = function(v) { switch (typeof v) { case 'string': return v; case 'boolean': return v ? 'true' : 'false'; case 'number': return isFinite(v) ? v : ''; default: return ''; } }; module.exports = function(obj, sep, eq, name) { sep = sep || '&'; eq = eq || '='; if (obj === null) { obj = undefined; } if (typeof obj === 'object') { return Object.keys(obj).map(function(k) { var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; if (Array.isArray(obj[k])) { return obj[k].map(function(v) { return ks + encodeURIComponent(stringifyPrimitive(v)); }).join(sep); } else { return ks + encodeURIComponent(stringifyPrimitive(obj[k])); } }).filter(Boolean).join(sep); } if (!name) return ''; return encodeURIComponent(stringifyPrimitive(name)) + eq + encodeURIComponent(stringifyPrimitive(obj)); }; querystring-0.2.1/index.d.ts000066400000000000000000000003461401250350700160070ustar00rootroot00000000000000import decodeFuncType from "./decode"; import encodeFuncType from "./encode"; export const decode: decodeFuncType; export const parse: decodeFuncType; export const encode: encodeFuncType; export const stringify: encodeFuncType; querystring-0.2.1/index.js000066400000000000000000000001771401250350700155550ustar00rootroot00000000000000'use strict'; exports.decode = exports.parse = require('./decode'); exports.encode = exports.stringify = require('./encode'); querystring-0.2.1/package.json000066400000000000000000000014671401250350700164010ustar00rootroot00000000000000{ "name": "querystring", "id": "querystring", "version": "0.2.1", "description": "Node's querystring module for all engines.", "keywords": [ "commonjs", "query", "querystring" ], "author": "Irakli Gozalishvili ", "main": "index.js", "repository": { "type": "git", "url": "git://github.com/Gozala/querystring.git", "web": "https://github.com/Gozala/querystring" }, "bugs": { "url": "http://github.com/Gozala/querystring/issues/" }, "devDependencies": { "test": "~0.x.0", "retape": "~0.x.0", "tape": "~0.1.5" }, "engines": { "node": ">=0.4.x" }, "scripts": { "test": "npm run test-node && npm run test-tap", "test-node": "node ./test/common-index.js", "test-tap": "node ./test/tap-index.js" }, "license": "MIT" } querystring-0.2.1/test/000077500000000000000000000000001401250350700150625ustar00rootroot00000000000000querystring-0.2.1/test/common-index.js000066400000000000000000000000661401250350700200170ustar00rootroot00000000000000"use strict"; require("test").run(require("./index"))querystring-0.2.1/test/index.js000066400000000000000000000171331401250350700165340ustar00rootroot00000000000000// Copyright Joyent, Inc. and other Node 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. "use strict"; // test using assert var qs = require('../'); // folding block, commented to pass gjslint // {{{ // [ wonkyQS, canonicalQS, obj ] var qsTestCases = [ ['foo=918854443121279438895193', 'foo=918854443121279438895193', {'foo': '918854443121279438895193'}], ['foo=bar', 'foo=bar', {'foo': 'bar'}], ['foo=bar&foo=quux', 'foo=bar&foo=quux', {'foo': ['bar', 'quux']}], ['foo=1&bar=2', 'foo=1&bar=2', {'foo': '1', 'bar': '2'}], ['my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F', 'my%20weird%20field=q1!2%22\'w%245%267%2Fz8)%3F', {'my weird field': 'q1!2"\'w$5&7/z8)?' }], ['foo%3Dbaz=bar', 'foo%3Dbaz=bar', {'foo=baz': 'bar'}], ['foo=baz=bar', 'foo=baz%3Dbar', {'foo': 'baz=bar'}], ['str=foo&arr=1&arr=2&arr=3&somenull=&undef=', 'str=foo&arr=1&arr=2&arr=3&somenull=&undef=', { 'str': 'foo', 'arr': ['1', '2', '3'], 'somenull': '', 'undef': ''}], [' foo = bar ', '%20foo%20=%20bar%20', {' foo ': ' bar '}], // disable test that fails ['foo=%zx', 'foo=%25zx', {'foo': '%zx'}], ['foo=%EF%BF%BD', 'foo=%EF%BF%BD', {'foo': '\ufffd' }], // See: https://github.com/joyent/node/issues/1707 ['hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz', 'hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz', { hasOwnProperty: 'x', toString: 'foo', valueOf: 'bar', __defineGetter__: 'baz' }], // See: https://github.com/joyent/node/issues/3058 ['foo&bar=baz', 'foo=&bar=baz', { foo: '', bar: 'baz' }] ]; // [ wonkyQS, canonicalQS, obj ] var qsColonTestCases = [ ['foo:bar', 'foo:bar', {'foo': 'bar'}], ['foo:bar;foo:quux', 'foo:bar;foo:quux', {'foo': ['bar', 'quux']}], ['foo:1&bar:2;baz:quux', 'foo:1%26bar%3A2;baz:quux', {'foo': '1&bar:2', 'baz': 'quux'}], ['foo%3Abaz:bar', 'foo%3Abaz:bar', {'foo:baz': 'bar'}], ['foo:baz:bar', 'foo:baz%3Abar', {'foo': 'baz:bar'}] ]; // [wonkyObj, qs, canonicalObj] var extendedFunction = function() {}; extendedFunction.prototype = {a: 'b'}; var qsWeirdObjects = [ [{regexp: /./g}, 'regexp=', {'regexp': ''}], [{regexp: new RegExp('.', 'g')}, 'regexp=', {'regexp': ''}], [{fn: function() {}}, 'fn=', {'fn': ''}], [{fn: new Function('')}, 'fn=', {'fn': ''}], [{math: Math}, 'math=', {'math': ''}], [{e: extendedFunction}, 'e=', {'e': ''}], [{d: new Date()}, 'd=', {'d': ''}], [{d: Date}, 'd=', {'d': ''}], [{f: new Boolean(false), t: new Boolean(true)}, 'f=&t=', {'f': '', 't': ''}], [{f: false, t: true}, 'f=false&t=true', {'f': 'false', 't': 'true'}], [{n: null}, 'n=', {'n': ''}], [{nan: NaN}, 'nan=', {'nan': ''}], [{inf: Infinity}, 'inf=', {'inf': ''}] ]; // }}} var qsNoMungeTestCases = [ ['', {}], ['foo=bar&foo=baz', {'foo': ['bar', 'baz']}], ['blah=burp', {'blah': 'burp'}], ['gragh=1&gragh=3&goo=2', {'gragh': ['1', '3'], 'goo': '2'}], ['frappucino=muffin&goat%5B%5D=scone&pond=moose', {'frappucino': 'muffin', 'goat[]': 'scone', 'pond': 'moose'}], ['trololol=yes&lololo=no', {'trololol': 'yes', 'lololo': 'no'}] ]; var stringifyTestCases = [ ['', {'foo': []}], ['bar=baz', {'foo': [], bar: 'baz'}], ] exports['test basic'] = function(assert) { assert.strictEqual('918854443121279438895193', qs.parse('id=918854443121279438895193').id, 'prase id=918854443121279438895193'); }; exports['test that the canonical qs is parsed properly'] = function(assert) { qsTestCases.forEach(function(testCase) { assert.deepEqual(testCase[2], qs.parse(testCase[0]), 'parse ' + testCase[0]); }); }; exports['test that the colon test cases can do the same'] = function(assert) { qsColonTestCases.forEach(function(testCase) { assert.deepEqual(testCase[2], qs.parse(testCase[0], ';', ':'), 'parse ' + testCase[0] + ' -> ; :'); }); }; exports['test the weird objects, that they get parsed properly'] = function(assert) { qsWeirdObjects.forEach(function(testCase) { assert.deepEqual(testCase[2], qs.parse(testCase[1]), 'parse ' + testCase[1]); }); }; exports['test non munge test cases'] = function(assert) { qsNoMungeTestCases.forEach(function(testCase) { assert.deepEqual(testCase[0], qs.stringify(testCase[1], '&', '=', false), 'stringify ' + JSON.stringify(testCase[1]) + ' -> & ='); }); }; exports['test the nested qs-in-qs case'] = function(assert) { var f = qs.parse('a=b&q=x%3Dy%26y%3Dz'); f.q = qs.parse(f.q); assert.deepEqual(f, { a: 'b', q: { x: 'y', y: 'z' } }, 'parse a=b&q=x%3Dy%26y%3Dz'); }; exports['test nested in colon'] = function(assert) { var f = qs.parse('a:b;q:x%3Ay%3By%3Az', ';', ':'); f.q = qs.parse(f.q, ';', ':'); assert.deepEqual(f, { a: 'b', q: { x: 'y', y: 'z' } }, 'parse a:b;q:x%3Ay%3By%3Az -> ; :'); }; exports['test stringifying'] = function(assert) { qsTestCases.forEach(function(testCase) { assert.equal(testCase[1], qs.stringify(testCase[2]), 'stringify ' + JSON.stringify(testCase[2])); }); stringifyTestCases.forEach(function(testCase) { assert.equal(testCase[0], qs.stringify(testCase[1]), 'stringify ' + JSON.stringify(testCase[1])); }); qsColonTestCases.forEach(function(testCase) { assert.equal(testCase[1], qs.stringify(testCase[2], ';', ':'), 'stringify ' + JSON.stringify(testCase[2]) + ' -> ; :'); }); qsWeirdObjects.forEach(function(testCase) { assert.equal(testCase[1], qs.stringify(testCase[0]), 'stringify ' + JSON.stringify(testCase[0])); }); }; exports['test stringifying nested'] = function(assert) { var f = qs.stringify({ a: 'b', q: qs.stringify({ x: 'y', y: 'z' }) }); assert.equal(f, 'a=b&q=x%3Dy%26y%3Dz', JSON.stringify({ a: 'b', 'qs.stringify -> q': { x: 'y', y: 'z' } })); var threw = false; try { qs.parse(undefined); } catch(error) { threw = true; } assert.ok(!threw, "does not throws on undefined"); }; exports['test nested in colon'] = function(assert) { var f = qs.stringify({ a: 'b', q: qs.stringify({ x: 'y', y: 'z' }, ';', ':') }, ';', ':'); assert.equal(f, 'a:b;q:x%3Ay%3By%3Az', 'stringify ' + JSON.stringify({ a: 'b', 'qs.stringify -> q': { x: 'y', y: 'z' } }) + ' -> ; : '); assert.deepEqual({}, qs.parse(), 'parse undefined'); }; querystring-0.2.1/test/tap-index.js000066400000000000000000000000641401250350700173110ustar00rootroot00000000000000"use strict"; require("retape")(require("./index"))