fix: non-sort filter keys getting removed

This commit is contained in:
Bobby 2022-09-24 08:21:01 +07:00
parent a44af208aa
commit 9af34a08f8
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09

View File

@ -1250,6 +1250,9 @@ page.uniquifyUploadsFilters = string => {
const uniquified = filtersArray const uniquified = filtersArray
.filter((v, i, a) => { .filter((v, i, a) => {
// Filter out invalid values
if (!v) return false
const match = v.match(/^(sort|orderby):(\w+)(:.*)?$/i) const match = v.match(/^(sort|orderby):(\w+)(:.*)?$/i)
// Uniquify sort/orderby filters by their keys // Uniquify sort/orderby filters by their keys
if (match && match[2]) { if (match && match[2]) {
@ -1259,7 +1262,7 @@ page.uniquifyUploadsFilters = string => {
return lastIndex === i return lastIndex === i
} }
// Uniquify other filters by exact string matches // Uniquify other filters by exact string matches
return i !== a.lastIndexOf(v) return i === a.lastIndexOf(v)
}) })
return uniquified return uniquified