8000 Merge pull request #27 from leonidborisenko/fully-parse-fn-name-with-… · stacktracejs/error-stack-parser@db4e196 · GitHub
[go: up one dir, main page]

Skip to content

Commit db4e196

Browse files
committed
Merge pull request #27 from leonidborisenko/fully-parse-fn-name-with-at-sign
Fully parse function names with @ in Error.stack
2 parents 8b76072 + bd3c9bb commit db4e196

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

error-stack-parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
} else {
120120
var tokens = line.split('@');
121121
var locationParts = this.extractLocation(tokens.pop());
122-
var functionName = tokens.shift() || undefined;
122+
var functionName = tokens.join('@') || undefined;
123123
return new StackFrame(functionName, undefined, locationParts[0], locationParts[1], locationParts[2], line);
124124
}
125125
}, this);

spec/error-stack-parser-spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ describe('ErrorStackParser', function () {
6565
expect(stackFrames[4]).toMatchStackFrame([undefined, undefined, 'http://localhost:8080/file.js', 33, 9]);
6666
});
6767

68+
it('should parse function names containing @ in Firefox 43 Error.stack', function () {
69+
var stackFrames = unit.parse(CapturedExceptions.FIREFOX_43_FUNCTION_NAME_WITH_AT_SIGN);
70+
expect(stackFrames).toBeTruthy();
71+
expect(stackFrames.length).toBe(2);
72+
expect(stackFrames[0]).toMatchStackFrame(['obj["@fn"]', undefined, 'Scratchpad/1', 10, 29]);
73+
expect(stackFrames[1]).toMatchStackFrame([undefined, undefined, 'Scratchpad/1', 11, 1]);
74+
});
75+
6876
it('should parse V8 Error.stack', function () {
6977
var stackFrames = unit.parse(CapturedExceptions.CHROME_15);
7078
expect(stackFrames).toBeTruthy();

spec/fixtures/captured-errors.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,17 @@ CapturedExceptions.FIREFOX_43_NESTED_EVAL = {
253253
"@http://localhost:8080/file.js:33:9"
254254
};
255255

256+
CapturedExceptions.FIREFOX_43_FUNCTION_NAME_WITH_AT_SIGN = {
257+
message: "Dummy error",
258+
name: "Error",
259+
stack: 'obj["@fn"]@Scratchpad/1:10:29\n' +
260+
"@Scratchpad/1:11:1\n" +
261+
"",
262+
fileName: "Scratchpad/1",
263+
lineNumber: 10,
264+
columnNumber: 29
265+
};
266+
256267
CapturedExceptions.SAFARI_6 = {
257268
message: "'null' is not an object (evaluating 'x.undef')",
258269
stack: "@http://path/to/file.js:48\n" +

0 commit comments

Comments
 (0)
0