-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Windows-style path in RewriteFrame's default iteratee #2319
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,12 @@ export class RewriteFrames implements Integration { | |
* @inheritDoc | ||
*/ | ||
private readonly _iteratee: StackFrameIteratee = (frame: StackFrame) => { | ||
if (frame.filename && frame.filename.startsWith('/')) { | ||
const base = this._root ? relative(this._root, frame.filename) : basename(frame.filename); | ||
// Check if the frame filename begins with `/` or a Windows-style prefix such as `C:\\` | ||
if (frame.filename && /^(\/|[A-Z]:\\)/.test(frame.filename)) { | ||
const filename = frame.filename | ||
.replace(/^[A-Z]:/, '') // remove Windows-style prefix | ||
.replace(/\\/g, '/'); // replace all `\\` instances with `/` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this has a subtle bug, because You can have, for example, Probably rare, but easy to fix - I think you just want to do these replacements only in the Windows case (where backslashes are not valid in paths), rather than all the time. |
||
const base = this._root ? relative(this._root, filename) : basename(filename); | ||
frame.filename = `app:///${base}`; | ||
} | ||
return frame; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows-style prefix is
C:\
, notC:\\
but the regexp is correct, so just the comment needs a small fix