Skip to content

Commit 8fd385d

Browse files
author
Armando Aguirre
committed
Refactored hashStackTrace
1 parent 6176375 commit 8fd385d

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/utils/hashStackTrace.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
import { createHash } from "crypto";
2-
3-
/** Matches any line containing 'tsserver.js' followed by line numbers. */
4-
const serverLinePattern = /tsserver\.js:(\d+)(?::(\d+))?/i;
1+
import { createHash } from "crypto";
52

63
export function getHash(methods: string[]): string {
74
const lines = methods.join("\n");
85
return createHash("md5").update(lines).digest("hex");
96
}
107

118
export function getHashForStack(stack: string): string {
12-
const stackLines = stack.split(/\r?\n|\r/);
13-
14-
const errorMessage = stackLines[1];
9+
const stackLines = stack.split(/\r?\n/);
1510

16-
// We will only match methods that contains tsserver. Everything else is ignored.
17-
return getHash([errorMessage, ...stackLines.filter(l => serverLinePattern.exec(l))]);
11+
return getHash(stackLines);
1812
}
1913

2014
export function getErrorMessageFromStack(stack: string): string {
21-
const stackLines = stack.split(/\r?\n|\r/, 2);
15+
const stackLines = stack.split(/\r?\n/, 2);
2216

2317
return stackLines[1];
2418
}

0 commit comments

Comments
 (0)