GeezerVison is showing github.com — querystring: use String.prototype.split's limit · lightsofapollo/node@27def4f
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/querystring.js +6-5Lines changed: 6 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -209,19 +209,20 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { |
209 | 209 | return obj; |
210 | 210 | } |
211 | 211 |
|
212 | | - qs = qs.split(sep); |
213 | | - |
214 | 212 | var maxKeys = 1000; |
215 | 213 | if (options && typeof options.maxKeys === 'number') { |
216 | 214 | maxKeys = options.maxKeys; |
217 | 215 | } |
218 | 216 |
|
219 | | - var len = qs.length; |
220 | 217 | // maxKeys <= 0 means that we should not limit keys count |
221 | | - if (maxKeys > 0 && len > maxKeys) { |
222 | | - len = maxKeys; |
| 218 | + if (maxKeys > 0) { |
| 219 | + qs = qs.split(sep, maxKeys); |
| 220 | + } else { |
| 221 | + qs = qs.split(sep); |
223 | 222 | } |
224 | 223 |
|
| 224 | + var len = qs.length; |
| 225 | + |
225 | 226 | var decode = QueryString.unescape; |
226 | 227 | if (options && typeof options.decodeURIComponent === 'function') { |
227 | 228 | decode = options.decodeURIComponent; |
|