Skip to content

Commit

Permalink
fix function and variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
parkiino committed Jun 10, 2024
1 parent e685ab4 commit 22d932a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
hasSimpleExecutableName,
OperatingSystem,
ConditionEntryField,
doesAnyValueContainWildcard,
validateWildcardInput,
validateHasWildcardWithWrongOperator,
validatePotentialWildcardInput,
validateFilePathInput,
Expand Down Expand Up @@ -40,12 +40,12 @@ describe('validatePotentialWildcardInput', () => {
});
});

describe('doesAnyValueContainWildcard', () => {
describe('validateWildcardInput', () => {
it('warns on wildcard for fields that are not file paths', () => {
expect(doesAnyValueContainWildcard('*')).toEqual(WILDCARD_WARNING);
expect(validateWildcardInput('*')).toEqual(WILDCARD_WARNING);
});
it('does not warn if no wildcard', () => {
expect(doesAnyValueContainWildcard('non-wildcard')).toEqual(undefined);
expect(validateWildcardInput('non-wildcard')).toEqual(undefined);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const validatePotentialWildcardInput = ({
if (field === 'file.path.text') {
return validateFilePathInput({ os, value: textInput });
}
return doesAnyValueContainWildcard(textInput);
return validateWildcardInput(textInput);
};

export const validateFilePathInput = ({
Expand Down Expand Up @@ -101,11 +101,11 @@ export const validateFilePathInput = ({
}
};

export const doesAnyValueContainWildcard = (value: string | string[]): string | undefined => {
export const validateWildcardInput = (value: string | string[]): string | undefined => {
const wildcardRegex = /[*?]/;
if (Array.isArray(value)) {
const test = value.some((v) => wildcardRegex.test(v));
if (test) {
const doesAnyValueContainWildcardInput = value.some((v) => wildcardRegex.test(v));
if (doesAnyValueContainWildcardInput) {
return WILDCARD_WARNING;
}
} else {
Expand All @@ -122,7 +122,7 @@ export const validateHasWildcardWithWrongOperator = ({
operator: TrustedAppEntryTypes | EventFiltersTypes;
value: string | string[];
}): boolean => {
if (operator !== 'wildcard' && doesAnyValueContainWildcard(value)) {
if (operator !== 'wildcard' && validateWildcardInput(value)) {
return true;
} else {
return false;
Expand Down

0 comments on commit 22d932a

Please sign in to comment.