Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ class StackUtils {
}
}
}
} else if (!closeParen && fname) {
file = `${fname} (${file}`;
fname = undefined;
}

if (fname) {
Expand Down Expand Up @@ -317,6 +320,8 @@ const re = new RegExp(
'^' +
// Sometimes we strip out the ' at' because it's noisy
'(?:\\s*at )?' +
// 'async ' prefix on async frames
'(?:async )?' +
// $1 = ctor if 'new'
'(?:(new) )?' +
// $2 = function name (can be literally anything)
Expand Down
36 changes: 36 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,42 @@ t.test('parseLine: handles parens', t => {
t.end();
});

t.test('parseLine: handles anonymous frames with parens in file path', t => {
const stackUtils = new StackUtils();
t.same(stackUtils.parseLine(' at /home/me/My App (beta)/index.js:4:11'), {
line: 4,
column: 11,
file: '/home/me/My App (beta)/index.js'
});
t.same(stackUtils.parseLine(' at C:\\Program Files (x86)\\app\\index.js:4:11'), {
line: 4,
column: 11,
file: 'C:/Program Files (x86)/app/index.js'
});
t.end();
});

t.test('parseLine: handles async frames', t => {
const stackUtils = new StackUtils();
t.same(stackUtils.parseLine(' at async /home/me/app/index.js:4:11'), {
line: 4,
column: 11,
file: '/home/me/app/index.js'
});
t.same(stackUtils.parseLine('async /home/me/app/index.js:4:11'), {
line: 4,
column: 11,
file: '/home/me/app/index.js'
});
t.same(stackUtils.parseLine(' at async foo (/home/me/app/index.js:4:11)'), {
line: 4,
column: 11,
file: '/home/me/app/index.js',
function: 'foo'
});
t.end();
});

function linuxStack1() {
return [
'Error: foo',
Expand Down