Skip to content

Commit 5652ba7

Browse files
committed
fix(browser): Set : as a part of gecko protocol regex group.
1 parent c610b17 commit 5652ba7

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

packages/browser/src/tracekit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const chrome = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|addre
4646
// gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
4747
// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
4848
// We need this specific case for now because we want no other regex to match.
49-
const gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
49+
const gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|safari-extension|safari-web-extension|capacitor)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
5050
const winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
5151
const geckoEval = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
5252
const chromeEval = /\((\S*)(?::(\d+))(?::(\d+))\)/;

packages/browser/test/unit/tracekit/original.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
FIREFOX_43_EVAL,
1616
FIREFOX_44_NS_EXCEPTION,
1717
FIREFOX_50_RESOURCE_URL,
18+
FIREFOX_FILE_IDENTIFIER,
1819
IE_10,
1920
IE_11,
2021
IE_11_EVAL,
@@ -869,6 +870,19 @@ describe('Tracekit - Original Tests', () => {
869870
});
870871
});
871872

873+
it('should parse Firefox errors with `file` inside an identifier', () => {
874+
const stackFrames = computeStackTrace(FIREFOX_FILE_IDENTIFIER);
875+
expect(stackFrames).toBeTruthy();
876+
expect(stackFrames.stack.length).toBe(3);
877+
expect(stackFrames.stack[2]).toEqual({
878+
args: [],
879+
column: 1018410,
880+
func: 'handleProfileResult',
881+
line: 146,
882+
url: 'https://www.random_website.com/main.4a4119c3cdfd10266d84.js',
883+
});
884+
});
885+
872886
it('should parse React Native errors on Android', () => {
873887
const stackFrames = computeStackTrace(ANDROID_REACT_NATIVE);
874888
expect(stackFrames).toBeTruthy();

packages/browser/test/unit/tracekit/originalfixtures.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,18 @@ export const FIREFOX_50_RESOURCE_URL = {
306306
name: 'TypeError',
307307
};
308308

309+
export const FIREFOX_FILE_IDENTIFIER = {
310+
stack:
311+
'us@https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js:1:296021\n' +
312+
'detectChanges@https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js:1:333807\n' +
313+
'handleProfileResult@https://www.random_website.com/main.4a4119c3cdfd10266d84.js:146:1018410\n',
314+
fileName: 'resource://path/data/content/bundle.js',
315+
lineNumber: 5529,
316+
columnNumber: 16,
317+
message: 'this.props.raw[this.state.dataSource].rows is undefined',
318+
name: 'TypeError',
319+
};
320+
309321
export const SAFARI_6 = {
310322
name: 'foo',
311323
message: "'null' is not an object (evaluating 'x.undef')",

0 commit comments

Comments
 (0)