Skip to content

Commit

Permalink
fix(tweaks): fix a bug with relative paths
Browse files Browse the repository at this point in the history
better detection of place and path

fixes #3
  • Loading branch information
tunnckoCore committed Mar 18, 2017
1 parent 83e5d28 commit f2921bd
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,19 @@ module.exports = function cleanStacktraceMetadata (plugin) {
return line
}

var m = /at\s+([^\s/]+)?\s?(.*)$/.exec(line)
// var m = line.match(/at (.+) \(?(.+)\)?$/)
/* istanbul ignore next */
if (!m) {
return line
var tmp = line.replace(/at\s+/, '')
var idx = tmp.indexOf(' ')
var place = ''
var filepath = ''

if (idx > 0) {
place = tmp.slice(0, idx)
filepath = tmp.slice(idx + 1)
} else {
filepath = tmp
}
m = m.filter(Boolean)

var filepath = (m.length === 3 ? m[2] : m[1])
filepath = filepath
.replace(/^\(/, '')
.replace(/\)$/, '')

Expand All @@ -105,8 +109,8 @@ module.exports = function cleanStacktraceMetadata (plugin) {
var info = {
line: +parts[1] || 0,
column: +parts[2] || 0,
filename: '' + filename,
place: m.length === 3 ? m[1] : ''
filename: filename,
place: place
}

return plugin(line, info, index) || line
Expand Down

0 comments on commit f2921bd

Please sign in to comment.