Skip to content

Commit aeae154

Browse files
committed
Handle stack frames with no line/column information. Fixes stacktracejs/stackframe#11
1 parent 6fed09a commit aeae154

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

dist/error-stack-parser.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,16 @@
6262
}
6363
},
6464

65-
// Separate line and column numbers from a URL-like string.
65+
// Separate line and column numbers from a string of the form: (URI:Line:Column)
6666
extractLocation: function ErrorStackParser$$extractLocation(urlLike) {
6767
// Fail-fast but return locations like "(native)"
6868
if (urlLike.indexOf(':') === -1) {
6969
return [urlLike];
7070
}
7171

72-
var locationParts = urlLike.replace(/[\(\)\s]/g, '').split(':');
73-
var lastNumber = locationParts.pop();
74-
var possibleNumber = locationParts[locationParts.length - 1];
75-
if (!isNaN(parseFloat(possibleNumber)) && isFinite(possibleNumber)) {
76-
var lineNumber = locationParts.pop();
77-
return [locationParts.join(':'), lineNumber, lastNumber];
78-
} else {
79-
return [locationParts.join(':'), lastNumber, undefined];
80-
}
72+
var regExp = /(.+?)(?:\:(\d+))?(?:\:(\d+))?$/g;
73+
var parts = regExp.exec(urlLike.replace(/[\(\)]/g, ''));
74+
return [parts[1], parts[2], parts[3]];
8175
},
8276

8377
parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {

dist/error-stack-parser.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)