Skip to content

Commit 4735ee0

Browse files
author
akuslular
committed
fix: pick by index of metod for cookies
1 parent 9a25cb2 commit 4735ee0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/universal/utils/lodash/pickByIndexOf.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1+
const isSomeKey = (item, cookiesKey) => {
2+
if (typeof item === "string") {
3+
return cookiesKey.indexOf(item) !== -1;
4+
}
5+
6+
if (typeof item?.value === "string") {
7+
if (item?.exact) {
8+
return cookiesKey === item.value;
9+
}
10+
return cookiesKey.indexOf(item?.value) !== -1;
11+
}
12+
13+
return false;
14+
};
15+
116
function pickByIndexOf(object, keys) {
217
if (object == null) {
318
return {};
419
}
520

621
const result = Object.keys(object).reduce((result, cookiesKey) => {
722
if (object[cookiesKey]) {
8-
if (keys.some(item => cookiesKey.indexOf(item) !== -1)) {
23+
if (keys.some(item => isSomeKey(item, cookiesKey))) {
924
return {
1025
...result,
1126
[cookiesKey]: object[cookiesKey]

0 commit comments

Comments
 (0)