Skip to content

Commit

Permalink
Decoding order_by query string value before passing to keysort()
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Dec 17, 2018
1 parent 39e08e5 commit 40b2134
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ function sort (arg, req) {

if (typeof req.parsed.search === "string" && req.parsed.searchParams.has("order_by") && Array.isArray(arg)) {
if (regex.unsortable.test(typeof arg[0]) === false && arg[0] !== null) {
output = keysort(clone(arg), req.parsed.search.replace("?", "").split("&").filter(i => regex.orderBy.test(i)).reduce((a, b) => [...a, b.replace(regex.orderBy, "")], []).join(", ").replace(/\%20|\+/g, " "));
output = keysort(clone(arg), req.parsed.search.replace("?", "").split("&").filter(i => regex.orderBy.test(i)).reduce((a, b) => [...a, decodeURIComponent(b.replace(regex.orderBy, ""))], []).join(", "));
} else {
// Primitives, regular Array.sort()
output = clone(arg).sort(retsu.sort);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tensō is an HTTP/HTTP2 REST API framework",
"version": "10.0.8",
"version": "10.0.9",
"homepage": "http://avoidwork.github.io/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down

0 comments on commit 40b2134

Please sign in to comment.