Skip to content

Commit

Permalink
chore: replaced in containsValue regex validation with includes (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
petruki authored Mar 29, 2024
1 parent 8bb7fc3 commit a3b7b3e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { getDomainById } from '../services/domain';
import { getEnvironments } from '../services/environment';
import { getTeams } from '../services/team';
import { verifyPermissions, verifyPermissionsCascade } from './permission';
import { some } from 'lodash';

const PATTERN_ALPHANUMERIC_SPACE = /^[a-zA-Z0-9_\- ]*$/;
const PATTERN_ALPHANUMERIC = /^[a-zA-Z0-9_-]*$/;
Expand Down Expand Up @@ -45,10 +44,15 @@ export function parseJSON(str) {
}

export function containsValue(arr, value) {
return some(arr, item => {
const regex = new RegExp(value);
return regex.test(item);
});
if (!arr?.length) {
return false;
}

for (const v of arr) {
if (v.includes(value)) {
return true;
}
}
}

export function formatInput(input,
Expand Down

0 comments on commit a3b7b3e

Please sign in to comment.