| 131 | }; |
| 132 | |
| 133 | var parseKeys = function parseQueryStringKeys(givenKey, val, options) { |
| 134 | if (!givenKey) { |
| 135 | return; |
| 136 | } |
| 137 | |
| 138 | // Transform dot notation to bracket notation |
| 139 | var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; |
| 140 | |
| 141 | // The regex chunks |
| 142 | |
| 143 | var brackets = /(\[[^[\]]*])/; |
| 144 | var child = /(\[[^[\]]*])/g; |
| 145 | |
| 146 | // Get the parent |
| 147 | |
| 148 | var segment = brackets.exec(key); |
| 149 | var parent = segment ? key.slice(0, segment.index) : key; |
| 150 | |
| 151 | // Stash the parent if it exists |
| 152 | |
| 153 | var keys = []; |
| 154 | if (parent) { |
| 155 | // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties |
| 156 | if (!options.plainObjects && has.call(Object.prototype, parent)) { |
| 157 | if (!options.allowPrototypes) { |
| 158 | return; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | keys.push(parent); |
| 163 | } |
| 164 | |
| 165 | // Loop through children appending to the array until we hit depth |
| 166 | |
| 167 | var i = 0; |
| 168 | while ((segment = child.exec(key)) !== null && i < options.depth) { |
| 169 | i += 1; |
| 170 | if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { |
| 171 | if (!options.allowPrototypes) { |
| 172 | return; |
| 173 | } |
| 174 | } |
| 175 | keys.push(segment[1]); |
| 176 | } |
| 177 | |
| 178 | // If there's a remainder, just add whatever is left |
| 179 | |
| 180 | if (segment) { |
| 181 | keys.push('[' + key.slice(segment.index) + ']'); |
| 182 | } |
| 183 | |
| 184 | return parseObject(keys, val, options); |
| 185 | }; |
| 186 | |
| 187 | var normalizeParseOptions = function normalizeParseOptions(opts) { |
| 188 | if (!opts) { |