Skip to content

Commit

Permalink
fix(matcher): allow passing / into string comparison for *
Browse files Browse the repository at this point in the history
regex pattern was change to accept any kind of caracter by using *

fix #18
  • Loading branch information
roggervalf committed Apr 30, 2020
1 parent 01e5554 commit 94da308
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/Matcher.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Matcher } from './Matcher';
//export default (): void => {

describe('Matcher Class', () => {
describe('when creating identity based policy', () => {
it("don't throw an error", () => {
Expand All @@ -13,10 +13,8 @@ describe('Matcher Class', () => {

describe('when match strings', () => {
it('returns true', () => {
expect(new Matcher('*').match('secrets::999/image')).toBe(true);
expect(new Matcher('secrets:123').match('secrets:123')).toBe(true);
expect(new Matcher('secrets:123:*').match('secrets:123:something')).toBe(
true
);
expect(
new Matcher('secrets:*:something').match('secrets:123:something')
).toBe(true);
Expand All @@ -33,4 +31,3 @@ describe('Matcher Class', () => {
});
});
});
//};
2 changes: 1 addition & 1 deletion src/Matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class Matcher {
) {
if (c === '*') {
this.hasSpecialCharacter = true;
re += '[^/]*?';
re += '.*?';
} else {
re += c;
}
Expand Down

0 comments on commit 94da308

Please sign in to comment.