Skip to content

Commit c43b5d5

Browse files
authored
Skip spaces when parsing stacktrace urls (ChromeDevTools#98)
1 parent c98a122 commit c43b5d5

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

front_end/panels/console/ErrorStackParser.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,40 @@ describe('ErrorStackParser', () => {
168168
});
169169
});
170170

171+
it('allows frames with parens in function names', () => {
172+
const frames = parseErrorStack(`Error Component Stack:
173+
at FlatList (http://example.com/a.js:6:3)
174+
at Animated(FlatList) (http://example.com/b.js:43:14)
175+
at RNTesterApp(RootComponent) (http://example.com/c.js:29:11)`);
176+
177+
assertNotNullOrUndefined(frames);
178+
assert.lengthOf(frames, 4);
179+
assert.deepStrictEqual(frames[1].link, {
180+
url: 'http://example.com/a.js' as Platform.DevToolsPath.UrlString,
181+
prefix: ' at FlatList (',
182+
suffix: ')',
183+
lineNumber: 5, // 0-based.
184+
columnNumber: 2, // 0-based.
185+
enclosedInBraces: true,
186+
});
187+
assert.deepStrictEqual(frames[2].link, {
188+
url: 'http://example.com/b.js' as Platform.DevToolsPath.UrlString,
189+
prefix: ' at Animated(FlatList) (',
190+
suffix: ')',
191+
lineNumber: 42, // 0-based.
192+
columnNumber: 13, // 0-based.
193+
enclosedInBraces: true,
194+
});
195+
assert.deepStrictEqual(frames[3].link, {
196+
url: 'http://example.com/c.js' as Platform.DevToolsPath.UrlString,
197+
prefix: ' at RNTesterApp(RootComponent) (',
198+
suffix: ')',
199+
lineNumber: 28, // 0-based.
200+
columnNumber: 10, // 0-based.
201+
enclosedInBraces: true,
202+
});
203+
});
204+
171205
it('correctly handles eval frames', () => {
172206
const url = 'http://www.chromium.org/foo.js' as Platform.DevToolsPath.UrlString;
173207
const frames = parseErrorStack(`Error: MyError

front_end/panels/console/ErrorStackParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export function parseSourcePositionsFromErrorStack(
5555
right--;
5656
enclosedInBraces = true;
5757
do {
58-
left = line.indexOf('(', left);
58+
left = line.indexOf(' (', left);
5959
if (left < 0) {
6060
return null;
6161
}
62-
left++;
62+
left += 2;
6363
if (!line.substring(left).startsWith('eval at ')) {
6464
break;
6565
}

0 commit comments

Comments
 (0)