Skip to content

Commit

Permalink
fix(core): support regex global flag in urlMatches
Browse files Browse the repository at this point in the history
  • Loading branch information
moander committed Oct 22, 2021
1 parent 6a8c2f2 commit 15b5c59
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/opentelemetry-core/src/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function urlMatches(url: string, urlToMatch: string | RegExp): boolean {
if (typeof urlToMatch === 'string') {
return url === urlToMatch;
} else {
return urlToMatch.test(url);
return !!url.match(urlToMatch);
}
}
/**
Expand Down
12 changes: 12 additions & 0 deletions packages/opentelemetry-core/test/utils/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,17 @@ describe('Core - Utils - url', () => {
);
});
});
describe('when regex has global flag', () => {
it('should return true', () => {
const ignoredUrls = [/myaddr/g];
for (let i = 0; i < 2; i++) {
assert.strictEqual(
isUrlIgnored(urlToTest, ignoredUrls),
true,
urlIgnored
);
}
});
});
});
});

0 comments on commit 15b5c59

Please sign in to comment.