1ecc202df6f004c23eec6c7d8f0b2401.json
18.7 KB
{"ast":null,"code":"'use strict';\n\nvar utils = require('./utils');\n\nvar has = Object.prototype.hasOwnProperty;\nvar defaults = {\n allowDots: false,\n allowPrototypes: false,\n arrayLimit: 20,\n decoder: utils.decode,\n delimiter: '&',\n depth: 5,\n parameterLimit: 1000,\n plainObjects: false,\n strictNullHandling: false\n};\n\nvar parseValues = function parseQueryStringValues(str, options) {\n var obj = {};\n var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\\?/, '') : str;\n var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;\n var parts = cleanStr.split(options.delimiter, limit);\n\n for (var i = 0; i < parts.length; ++i) {\n var part = parts[i];\n var bracketEqualsPos = part.indexOf(']=');\n var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;\n var key, val;\n\n if (pos === -1) {\n key = options.decoder(part, defaults.decoder);\n val = options.strictNullHandling ? null : '';\n } else {\n key = options.decoder(part.slice(0, pos), defaults.decoder);\n val = options.decoder(part.slice(pos + 1), defaults.decoder);\n }\n\n if (has.call(obj, key)) {\n obj[key] = [].concat(obj[key]).concat(val);\n } else {\n obj[key] = val;\n }\n }\n\n return obj;\n};\n\nvar parseObject = function (chain, val, options) {\n var leaf = val;\n\n for (var i = chain.length - 1; i >= 0; --i) {\n var obj;\n var root = chain[i];\n\n if (root === '[]') {\n obj = [];\n obj = obj.concat(leaf);\n } else {\n obj = options.plainObjects ? Object.create(null) : {};\n var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;\n var index = parseInt(cleanRoot, 10);\n\n if (!isNaN(index) && root !== cleanRoot && String(index) === cleanRoot && index >= 0 && options.parseArrays && index <= options.arrayLimit) {\n obj = [];\n obj[index] = leaf;\n } else {\n obj[cleanRoot] = leaf;\n }\n }\n\n leaf = obj;\n }\n\n return leaf;\n};\n\nvar parseKeys = function parseQueryStringKeys(givenKey, val, options) {\n if (!givenKey) {\n return;\n } // Transform dot notation to bracket notation\n\n\n var key = options.allowDots ? givenKey.replace(/\\.([^.[]+)/g, '[$1]') : givenKey; // The regex chunks\n\n var brackets = /(\\[[^[\\]]*])/;\n var child = /(\\[[^[\\]]*])/g; // Get the parent\n\n var segment = brackets.exec(key);\n var parent = segment ? key.slice(0, segment.index) : key; // Stash the parent if it exists\n\n var keys = [];\n\n if (parent) {\n // If we aren't using plain objects, optionally prefix keys\n // that would overwrite object prototype properties\n if (!options.plainObjects && has.call(Object.prototype, parent)) {\n if (!options.allowPrototypes) {\n return;\n }\n }\n\n keys.push(parent);\n } // Loop through children appending to the array until we hit depth\n\n\n var i = 0;\n\n while ((segment = child.exec(key)) !== null && i < options.depth) {\n i += 1;\n\n if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {\n if (!options.allowPrototypes) {\n return;\n }\n }\n\n keys.push(segment[1]);\n } // If there's a remainder, just add whatever is left\n\n\n if (segment) {\n keys.push('[' + key.slice(segment.index) + ']');\n }\n\n return parseObject(keys, val, options);\n};\n\nmodule.exports = function (str, opts) {\n var options = opts ? utils.assign({}, opts) : {};\n\n if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {\n throw new TypeError('Decoder has to be a function.');\n }\n\n options.ignoreQueryPrefix = options.ignoreQueryPrefix === true;\n options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;\n options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;\n options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;\n options.parseArrays = options.parseArrays !== false;\n options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;\n options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;\n options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;\n options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;\n options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;\n options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;\n\n if (str === '' || str === null || typeof str === 'undefined') {\n return options.plainObjects ? Object.create(null) : {};\n }\n\n var tempObj = typeof str === 'string' ? parseValues(str, options) : str;\n var obj = options.plainObjects ? Object.create(null) : {}; // Iterate over the keys and setup the new object\n\n var keys = Object.keys(tempObj);\n\n for (var i = 0; i < keys.length; ++i) {\n var key = keys[i];\n var newObj = parseKeys(key, tempObj[key], options);\n obj = utils.merge(obj, newObj, options);\n }\n\n return utils.compact(obj);\n};","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/qs/lib/parse.js"],"names":["utils","require","has","Object","prototype","hasOwnProperty","defaults","allowDots","allowPrototypes","arrayLimit","decoder","decode","delimiter","depth","parameterLimit","plainObjects","strictNullHandling","parseValues","parseQueryStringValues","str","options","obj","cleanStr","ignoreQueryPrefix","replace","limit","Infinity","undefined","parts","split","i","length","part","bracketEqualsPos","indexOf","pos","key","val","slice","call","concat","parseObject","chain","leaf","root","create","cleanRoot","charAt","index","parseInt","isNaN","String","parseArrays","parseKeys","parseQueryStringKeys","givenKey","brackets","child","segment","exec","parent","keys","push","module","exports","opts","assign","TypeError","isRegExp","tempObj","newObj","merge","compact"],"mappings":"AAAA;;AAEA,IAAIA,KAAK,GAAGC,OAAO,CAAC,SAAD,CAAnB;;AAEA,IAAIC,GAAG,GAAGC,MAAM,CAACC,SAAP,CAAiBC,cAA3B;AAEA,IAAIC,QAAQ,GAAG;AACXC,EAAAA,SAAS,EAAE,KADA;AAEXC,EAAAA,eAAe,EAAE,KAFN;AAGXC,EAAAA,UAAU,EAAE,EAHD;AAIXC,EAAAA,OAAO,EAAEV,KAAK,CAACW,MAJJ;AAKXC,EAAAA,SAAS,EAAE,GALA;AAMXC,EAAAA,KAAK,EAAE,CANI;AAOXC,EAAAA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AAYlD,GAAZ,EAAiBiD,MAAjB,EAAyBlD,OAAzB,CAAN;AACH;;AAED,SAAOpB,KAAK,CAACwE,OAAN,CAAcnD,GAAd,CAAP;AACH,CApCD","sourcesContent":["'use strict';\n\nvar utils = require('./utils');\n\nvar has = Object.prototype.hasOwnProperty;\n\nvar defaults = {\n allowDots: false,\n allowPrototypes: false,\n arrayLimit: 20,\n decoder: utils.decode,\n delimiter: '&',\n depth: 5,\n parameterLimit: 1000,\n plainObjects: false,\n strictNullHandling: false\n};\n\nvar parseValues = function parseQueryStringValues(str, options) {\n var obj = {};\n var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\\?/, '') : str;\n var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;\n var parts = cleanStr.split(options.delimiter, limit);\n\n for (var i = 0; i < parts.length; ++i) {\n var part = parts[i];\n\n var bracketEqualsPos = part.indexOf(']=');\n var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;\n\n var key, val;\n if (pos === -1) {\n key = options.decoder(part, defaults.decoder);\n val = options.strictNullHandling ? null : '';\n } else {\n key = options.decoder(part.slice(0, pos), defaults.decoder);\n val = options.decoder(part.slice(pos + 1), defaults.decoder);\n }\n if (has.call(obj, key)) {\n obj[key] = [].concat(obj[key]).concat(val);\n } else {\n obj[key] = val;\n }\n }\n\n return obj;\n};\n\nvar parseObject = function (chain, val, options) {\n var leaf = val;\n\n for (var i = chain.length - 1; i >= 0; --i) {\n var obj;\n var root = chain[i];\n\n if (root === '[]') {\n obj = [];\n obj = obj.concat(leaf);\n } else {\n obj = options.plainObjects ? Object.create(null) : {};\n var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;\n var index = parseInt(cleanRoot, 10);\n if (\n !isNaN(index)\n && root !== cleanRoot\n && String(index) === cleanRoot\n && index >= 0\n && (options.parseArrays && index <= options.arrayLimit)\n ) {\n obj = [];\n obj[index] = leaf;\n } else {\n obj[cleanRoot] = leaf;\n }\n }\n\n leaf = obj;\n }\n\n return leaf;\n};\n\nvar parseKeys = function parseQueryStringKeys(givenKey, val, options) {\n if (!givenKey) {\n return;\n }\n\n // Transform dot notation to bracket notation\n var key = options.allowDots ? givenKey.replace(/\\.([^.[]+)/g, '[$1]') : givenKey;\n\n // The regex chunks\n\n var brackets = /(\\[[^[\\]]*])/;\n var child = /(\\[[^[\\]]*])/g;\n\n // Get the parent\n\n var segment = brackets.exec(key);\n var parent = segment ? key.slice(0, segment.index) : key;\n\n // Stash the parent if it exists\n\n var keys = [];\n if (parent) {\n // If we aren't using plain objects, optionally prefix keys\n // that would overwrite object prototype properties\n if (!options.plainObjects && has.call(Object.prototype, parent)) {\n if (!options.allowPrototypes) {\n return;\n }\n }\n\n keys.push(parent);\n }\n\n // Loop through children appending to the array until we hit depth\n\n var i = 0;\n while ((segment = child.exec(key)) !== null && i < options.depth) {\n i += 1;\n if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {\n if (!options.allowPrototypes) {\n return;\n }\n }\n keys.push(segment[1]);\n }\n\n // If there's a remainder, just add whatever is left\n\n if (segment) {\n keys.push('[' + key.slice(segment.index) + ']');\n }\n\n return parseObject(keys, val, options);\n};\n\nmodule.exports = function (str, opts) {\n var options = opts ? utils.assign({}, opts) : {};\n\n if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {\n throw new TypeError('Decoder has to be a function.');\n }\n\n options.ignoreQueryPrefix = options.ignoreQueryPrefix === true;\n options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;\n options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;\n options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;\n options.parseArrays = options.parseArrays !== false;\n options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;\n options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;\n options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;\n options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;\n options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;\n options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;\n\n if (str === '' || str === null || typeof str === 'undefined') {\n return options.plainObjects ? Object.create(null) : {};\n }\n\n var tempObj = typeof str === 'string' ? parseValues(str, options) : str;\n var obj = options.plainObjects ? Object.create(null) : {};\n\n // Iterate over the keys and setup the new object\n\n var keys = Object.keys(tempObj);\n for (var i = 0; i < keys.length; ++i) {\n var key = keys[i];\n var newObj = parseKeys(key, tempObj[key], options);\n obj = utils.merge(obj, newObj, options);\n }\n\n return utils.compact(obj);\n};\n"]},"metadata":{},"sourceType":"script"}