Skip to content

Commit d614fed

Browse files
committed
Fixing findFunctionName regex to conform to spec, closes stacktracejs#42
1 parent 8f476e4 commit d614fed

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

stacktrace.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,14 +402,13 @@ printStackTrace.implementation.prototype = {
402402
findFunctionName: function(source, lineNo) {
403403
// FIXME findFunctionName fails for compressed source
404404
// (more than one function on the same line)
405-
// TODO use captured args
406405
// function {name}({args}) m[1]=name m[2]=args
407406
var reFunctionDeclaration = /function\s+([^(]*?)\s*\(([^)]*)\)/;
408407
// {name} = function ({args}) TODO args capture
409408
// /['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*function(?:[^(]*)/
410-
var reFunctionExpression = /['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*function\b/;
409+
var reFunctionExpression = /['"]?([$_A-Za-z][$_A-Za-z0-9]*)['"]?\s*[:=]\s*function\b/;
411410
// {name} = eval()
412-
var reFunctionEvaluation = /['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*(?:eval|new Function)\b/;
411+
var reFunctionEvaluation = /['"]?([$_A-Za-z][$_A-Za-z0-9]*)['"]?\s*[:=]\s*(?:eval|new Function)\b/;
413412
// Walk backwards in the source lines until we find
414413
// the line which matches one of the patterns above
415414
var code = "", line, maxLines = Math.min(lineNo, 20), m, commentPos;

0 commit comments

Comments
 (0)