stacktracey
Advanced tools
Comparing version 2.0.19 to 2.1.0
{ | ||
"name": "stacktracey", | ||
"version": "2.0.19", | ||
"version": "2.1.0", | ||
"description": "Parses call stacks. Reads sources. Clean & filtered output. Sourcemaps. Node & browsers.", | ||
@@ -5,0 +5,0 @@ "main": "stacktracey", |
@@ -76,11 +76,16 @@ "use strict"; | ||
const fileRelative = this.relativePath (e.file || '') | ||
let fileRelative = this.relativePath (e.file || '') | ||
const externalDomainMatch = fileRelative.match (/^.*\:\/\/?\/?([^\/]+)\/(.*)/) | ||
const externalDomain = externalDomainMatch ? externalDomainMatch[1] : undefined | ||
fileRelative = externalDomainMatch ? externalDomainMatch[2] : fileRelative | ||
return O.assign (e, { | ||
calleeShort: e.calleeShort || lastOf ((e.callee || '').split ('.')), | ||
fileRelative: fileRelative, | ||
fileShort: this.shortenPath (fileRelative), | ||
fileName: lastOf ((e.file || '').split ('/')), | ||
thirdParty: this.isThirdParty (fileRelative) && !e.index | ||
calleeShort: e.calleeShort || lastOf ((e.callee || '').split ('.')), | ||
fileRelative: fileRelative, | ||
fileShort: this.shortenPath (fileRelative), | ||
fileName: lastOf ((e.file || '').split ('/')), | ||
thirdParty: this.isThirdParty (fileRelative, externalDomain) && !e.index, | ||
externalDomain: externalDomain | ||
}) | ||
@@ -96,7 +101,8 @@ } | ||
relativePath (fullPath) { | ||
return nixSlashes (pathToRelative (pathRoot, fullPath)).replace (/^.*\:\/\/?\/?/, '') | ||
return nixSlashes (pathToRelative (pathRoot, fullPath)) | ||
} | ||
isThirdParty (relativePath) { | ||
return (relativePath[0] === '~') || // webpack-specific heuristic | ||
isThirdParty (relativePath, externalDomain) { | ||
return externalDomain || | ||
(relativePath[0] === '~') || // webpack-specific heuristic | ||
(relativePath[0] === '/') || // external source | ||
@@ -103,0 +109,0 @@ (relativePath.indexOf ('node_modules') === 0) || |
23
test.js
@@ -303,3 +303,4 @@ "use strict"; | ||
it('parses "eval at" stuff', () => { | ||
it ('parses "eval at" stuff', () => { | ||
function bar() { | ||
@@ -315,2 +316,22 @@ const entry = new StackTracey().items[1] | ||
}) | ||
it.only ('recognizes externalDomain', () => { | ||
const stack = | ||
[ | ||
'Error', | ||
' at foo (test.js:38:22)', | ||
' at bar (http://shmoogle.google.com/hohoho/test.js:38:22)', | ||
].join ('\n') | ||
const items = new StackTracey(stack).items | ||
;(items[0].externalDomain === undefined).should.be.true | ||
items[1].externalDomain.should.equal('shmoogle.google.com') | ||
items[0].thirdParty.should.be.false | ||
items[1].thirdParty.should.be.true | ||
items[1].fileRelative.should.equal('hohoho/test.js') | ||
}) | ||
}) | ||
@@ -317,0 +338,0 @@ |
44024
557