stack-utils
Advanced tools
Comparing version 1.0.0 to 1.0.1
73
index.js
@@ -213,18 +213,24 @@ module.exports = StackUtils; | ||
'(?:(new) )?' + | ||
// Object.method [as foo] (, maybe | ||
// $2 = function name | ||
// $3 = method name | ||
'(?:([^\\(\\[]*)(?: \\[as ([^\\]]+)\\])? \\()?' + | ||
// $2 = function name (can be literally anything) | ||
// May contain method at the end as [as xyz] | ||
'(?:(.*?) \\()?' + | ||
// (eval at <anonymous> (file.js:1:1), | ||
// $4 = eval origin | ||
// $5:$6:$7 are eval file/line/col, but not normally reported | ||
// $3 = eval origin | ||
// $4:$5:$6 are eval file/line/col, but not normally reported | ||
'(?:eval at ([^ ]+) \\((.+?):(\\d+):(\\d+)\\), )?' + | ||
// file:line:col | ||
// $8:$9:$10 | ||
// $11 = 'native' if native | ||
// $7:$8:$9 | ||
// $10 = 'native' if native | ||
'(?:(.+?):(\\d+):(\\d+)|(native))' + | ||
// maybe close the paren, then end | ||
'\\)?$' | ||
// if $11 is ), then we only allow balanced parens in the filename | ||
// any imbalance is placed on the fname. This is a heuristic, and | ||
// bound to be incorrect in some edge cases. The bet is that | ||
// having weird characters in method names is more common than | ||
// having weird characters in filenames, which seems reasonable. | ||
'(\\)?)$' | ||
); | ||
var methodRe = /^(.*?) \[as (.*?)\]$/; | ||
StackUtils.prototype.parseLine = function parseLine(line) { | ||
@@ -238,11 +244,11 @@ var match = line && line.match(re); | ||
var fname = match[2]; | ||
var meth = match[3]; | ||
var evalOrigin = match[4]; | ||
var evalFile = match[5]; | ||
var evalLine = Number(match[6]); | ||
var evalCol = Number(match[7]); | ||
var file = match[8]; | ||
var lnum = match[9]; | ||
var col = match[10]; | ||
var native = match[11] === 'native'; | ||
var evalOrigin = match[3]; | ||
var evalFile = match[4]; | ||
var evalLine = Number(match[5]); | ||
var evalCol = Number(match[6]); | ||
var file = match[7]; | ||
var lnum = match[8]; | ||
var col = match[9]; | ||
var native = match[10] === 'native'; | ||
var closeParen = match[11] === ')'; | ||
@@ -259,2 +265,33 @@ var res = {}; | ||
if (closeParen && file) { | ||
// make sure parens are balanced | ||
// if we have a file like "asdf) [as foo] (xyz.js", then odds are | ||
// that the fname should be += " (asdf) [as foo]" and the file | ||
// should be just "xyz.js" | ||
// walk backwards from the end to find the last unbalanced ( | ||
var closes = 0; | ||
for (var i = file.length - 1; i > 0; i--) { | ||
if (file.charAt(i) === ')') { | ||
closes ++; | ||
} else if (file.charAt(i) === '(' && file.charAt(i - 1) === ' ') { | ||
closes --; | ||
if (closes === -1 && file.charAt(i - 1) === ' ') { | ||
var before = file.substr(0, i - 1); | ||
var after = file.substr(i + 1); | ||
file = after; | ||
fname += ' (' + before; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
if (fname) { | ||
var methodMatch = fname.match(methodRe); | ||
if (methodMatch) { | ||
fname = methodMatch[1]; | ||
var meth = methodMatch[2]; | ||
} | ||
} | ||
this._setFile(res, file); | ||
@@ -261,0 +298,0 @@ |
{ | ||
"name": "stack-utils", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Captures and cleans stack traces", | ||
@@ -16,3 +16,6 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "tap test/*.js --cov" | ||
"test": "tap test/*.js --100 -J", | ||
"preversion": "npm test", | ||
"postversion": "npm publish", | ||
"postpublish": "git push origin --all; git push origin --tags" | ||
}, | ||
@@ -33,4 +36,4 @@ "files": [ | ||
"q": "^1.4.1", | ||
"tap": "^10.0.0" | ||
"tap": "^10.3.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
13516
269
0