Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit a8ef127

Browse files
committed
use Array.prototype.some() instead of ...map().includes()
1 parent ed46180 commit a8ef127

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

rest_server/src/controllers/item_controller.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ async function checkReadPermission(userInfo, item, categories) {
1616
if (categories === undefined) {
1717
categories = await MarketplaceItem.getCategories(item);
1818
}
19-
const categoriesArray = categories.map(category => category.name);
2019
if (
21-
!categoriesArray.includes(OFFICIAL_EXAMPLE) &&
20+
!categories.some(category => category.name === OFFICIAL_EXAMPLE) &&
2221
userInfo.username === item.author
2322
) {
2423
return true;
@@ -43,9 +42,8 @@ async function checkWritePermission(tokenInfo, item, categories) {
4342
if (categories === undefined) {
4443
categories = await MarketplaceItem.getCategories(item);
4544
}
46-
const categoriesArray = categories.map(category => category.name);
4745
if (
48-
!categoriesArray.includes(OFFICIAL_EXAMPLE) &&
46+
!categories.some(category => category.name === OFFICIAL_EXAMPLE) &&
4947
tokenInfo.username === item.author
5048
) {
5149
return true;

0 commit comments

Comments
 (0)