We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
parameterCount
1 parent ccad155 commit f27f2ceCopy full SHA for f27f2ce
lib/types/urlencoded.js
@@ -208,19 +208,9 @@ function getCharset (req) {
208
*/
209
210
function parameterCount (body, limit) {
211
- var count = 0
212
- var index = 0
+ var len = body.split('&').length
213
214
- while ((index = body.indexOf('&', index)) !== -1) {
215
- count++
216
- index++
217
-
218
- if (count === limit) {
219
- return undefined
220
- }
221
222
223
- return count
+ return len > limit ? undefined : len - 1
224
}
225
226
/**
package.json
@@ -44,7 +44,6 @@
44
"lint": "eslint .",
45
"test": "mocha --reporter spec --check-leaks test/",
46
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
47
48
"test-cov": "nyc --reporter=html --reporter=text npm test"
49
50
0 commit comments