Skip to content

Commit

Permalink
Merge pull request #362 from talanta/master
Browse files Browse the repository at this point in the history
Remove Url.parse limit of parameters (default 1000)
  • Loading branch information
pmcnr-hx authored Jan 31, 2018
2 parents c89d966 + 1d998c9 commit 6242b4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions documentation/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ jsonApi.setConfig({
// such as the maximum allowed body size (default is 100kb). All the options are
// documented at https://github.com/expressjs/body-parser#bodyparserjsonoptions
bodyParserJsonOpts: {
limit: '256kb',
}
limit: '256kb'
},
// (optional) queryStringParsingParameterLimit allows to
// override the default limit of 1000 parameters in query string parsing,
// documented at : https://github.com/ljharb/qs
queryStringParsingParameterLimit: Infinity
});
```

Expand Down
6 changes: 4 additions & 2 deletions lib/rerouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ rerouter.route = (newRequest, callback) => {

const path = rerouter._generateSanePath(newRequest)
const route = rerouter._pickFirstMatchingRoute(validRoutes, path)

const qsOpts = jsonApi._apiConfig.queryStringParsingParameterLimit
? { parameterLimit: jsonApi._apiConfig.queryStringParsingParameterLimit }
: { }
const req = {
url: newRequest.uri,
originalUrl: newRequest.originalRequest.originalUrl,
headers: newRequest.originalRequest.headers,
cookies: newRequest.originalRequest.cookies,
params: rerouter._mergeParams(url.parse(newRequest.uri.split('?')[1] || { }), newRequest.params)
params: rerouter._mergeParams(url.parse(newRequest.uri.split('?')[1] || { }, qsOpts), newRequest.params)
}
rerouter._extendUrlParamsOntoReq(route, path, req)

Expand Down

0 comments on commit 6242b4a

Please sign in to comment.