MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / isMatchingPattern

Function isMatchingPattern

packages/core/src/utils/string.ts:100–120  ·  view source on GitHub ↗
(
  value: string,
  pattern: RegExp | string | ((value: string) => boolean),
  requireExactStringMatch: boolean = false,
)

Source from the content-addressed store, hash-verified

98 * `pattern` if it contains `pattern`. Only applies to string-type patterns.
99 */
100export function isMatchingPattern(
101 value: string,
102 pattern: RegExp | string | ((value: string) => boolean),
103 requireExactStringMatch: boolean = false,
104): boolean {
105 if (!isString(value)) {
106 return false;
107 }
108
109 if (isRegExp(pattern)) {
110 return pattern.test(value);
111 }
112 if (isString(pattern)) {
113 return requireExactStringMatch ? value === pattern : value.includes(pattern);
114 }
115 if (typeof pattern === 'function') {
116 return pattern(value);
117 }
118
119 return false;
120}
121
122/**
123 * Test the given string against an array of strings and regexes. By default, string matching is done on a

Callers 6

string.test.tsFile · 0.90
shouldIgnoreSpanFunction · 0.90
_matchesAttributeValueFunction · 0.90
shouldExcludeFunction · 0.90
isMatchingReasonFunction · 0.90
stringMatchesSomePatternFunction · 0.85

Calls 3

isStringFunction · 0.90
isRegExpFunction · 0.90
testMethod · 0.65

Tested by

no test coverage detected