| 69 | // We cannot call this variable `chrome` because it can conflict with global `chrome` variable in certain environments |
| 70 | // See: https://github.com/getsentry/sentry-javascript/issues/6880 |
| 71 | const chromeStackParserFn: StackLineParserFn = line => { |
| 72 | const dataUriMatch = line.match(chromeDataUriRegex); |
| 73 | if (dataUriMatch) { |
| 74 | return { |
| 75 | filename: `<data:${dataUriMatch[2]}>`, |
| 76 | function: dataUriMatch[1], |
| 77 | }; |
| 78 | } |
| 79 | |
| 80 | // If the stack line has no function name, we need to parse it differently |
| 81 | const noFnParts = chromeRegexNoFnName.exec(line) as null | [string, string, string, string]; |
| 82 | |
| 83 | if (noFnParts) { |
| 84 | const [, filename, line, col] = noFnParts; |
| 85 | return createFrame(filename, UNKNOWN_FUNCTION, +line, +col); |
| 86 | } |
| 87 | |
| 88 | const parts = chromeRegex.exec(line) as null | [string, string, string, string, string]; |
| 89 | |
| 90 | if (parts) { |
| 91 | const isEval = parts[2]?.indexOf('eval') === 0; // start of line |
| 92 | |
| 93 | if (isEval) { |
| 94 | const subMatch = chromeEvalRegex.exec(parts[2]) as null | [string, string, string, string]; |
| 95 | |
| 96 | if (subMatch) { |
| 97 | // throw out eval line/column and use top-most line/column number |
| 98 | parts[2] = subMatch[1]; // url |
| 99 | parts[3] = subMatch[2]; // line |
| 100 | parts[4] = subMatch[3]; // column |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now |
| 105 | // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable) |
| 106 | const [func, filename] = extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2]); |
| 107 | |
| 108 | return createFrame(filename, func, parts[3] ? +parts[3] : undefined, parts[4] ? +parts[4] : undefined); |
| 109 | } |
| 110 | |
| 111 | return; |
| 112 | }; |
| 113 | |
| 114 | export const chromeStackLineParser: StackLineParser = [CHROME_PRIORITY, chromeStackParserFn]; |
| 115 |
nothing calls this directly
no test coverage detected