Skip to content

Commit

Permalink
support nested field selection for icons
Browse files Browse the repository at this point in the history
  • Loading branch information
InventivetalentDev committed Apr 24, 2023
1 parent 2b923dc commit 548bff5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion util.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module.exports.resourceListFields = [
"updateDate",
"downloads",
"icon",
"icon.url",
"icon.data",
"author",
"premium",
"existenceStatus",
Expand Down Expand Up @@ -52,6 +54,8 @@ module.exports.resourceAllFields = [
"updateDate",
"downloads",
"icon",
"icon.url",
"icon.data",
"reviews",
"premium",
"price",
Expand Down Expand Up @@ -179,6 +183,18 @@ function selectFields(req, defaultFields) {
allowedFields.push(fieldSplit[i]);
}
}

// hack to avoid path collisions
if (allowedFields.includes('icon')) {
let urlInd = allowedFields.indexOf('icon.url');
if (urlInd !== -1) {
allowedFields.splice(urlInd, 1);
}
let dataInd = allowedFields.indexOf('icon.data');
if (dataInd !== -1) {
allowedFields.splice(dataInd, 1);
}
}
return allowedFields.join(" ");
}

Expand Down Expand Up @@ -300,6 +316,6 @@ module.exports.redirectToMaster = function (req, res, config) {
}
};

module.exports.escapeRegex = function(string) {
module.exports.escapeRegex = function (string) {
return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}

0 comments on commit 548bff5

Please sign in to comment.