stacktracejs / error-stack-parser

Extract meaning from JS Errors
https://www.stacktracejs.com/#!/docs/error-stack-parser
MIT License
456 stars 52 forks source link

Fix parsing of error stacks where url paths contain @ symbols #42

Closed bengourley closed 6 years ago

bengourley commented 6 years ago

When the URL path of a stackframe contains @, the parseFFOrSafari() function returns an incomplete fileName value.

e.g. given the string:

"who@http://localhost:5000/misc/@stuff/foo.js:3:9"

expected fileName is "http://localhost:5000/misc/@stuff/foo.js" actual fileName is "stuff/foo.js"

Description

Calling .split('@') on the stackframe string split it into an arbitrary number of chunks depending on whether there was an @ in the URL or in the method name.

I created a rather gnarly looking regex (after exhausting other options) to extract everything after the first @, unless it was preceded by something like obj["@method"], in which case it will extract everything after the first @ preceded by the enclosing quotes.

Motivation and Context

We're using this module on bugsnag-js and a customer of ours reported an issue with errors coming from URLs containing @ but only in Firefox.

How Has This Been Tested?

Cases have been added to the automated test suite.

Types of changes

Checklist: