Skip to content

Commit 5013d05

Browse files
Handle old and new backtrace format, fixes 1477 (errbit#1497)
1 parent f2deb43 commit 5013d05

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

app/models/backtrace.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ class Backtrace
22
include Mongoid::Document
33
include Mongoid::Timestamps
44

5-
IN_APP_PATH = %r{^\[PROJECT_ROOT\](?!(\/vendor))/?}
6-
GEMS_PATH = %r{\[GEM_ROOT\]\/gems\/([^\/]+)}
5+
IN_APP_PATH = %r{^(?:\[|/)PROJECT_ROOT\]?(?!(/vendor))/?}
6+
GEMS_PATH = %r{(?:\[|/)GEM_ROOT\]?/gems/([^/]+)}
77

88
field :fingerprint
99
field :lines

spec/decorators/backtrace_line_decorator_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
file: '[PROJECT_ROOT]/path/to/file/ea315ea4.rb',
1212
method: :instance_eval)
1313
end
14+
let(:backtrace_line_in_app_slashes) do
15+
described_class.new(
16+
number: 884,
17+
file: '/PROJECT_ROOT/path/to/file/ea315ea4.rb',
18+
method: :instance_eval)
19+
end
1420
let(:backtrace_line_no_file) do
1521
described_class.new(number: 884, method: :instance_eval)
1622
end
@@ -47,6 +53,16 @@
4753
end
4854
end
4955

56+
describe '#decorated_path' do
57+
it 'parses old backtrace format with square brackets' do
58+
expect(backtrace_line_in_app.decorated_path).to eq 'path/to/file/'
59+
end
60+
61+
it 'parses new backtrace format with slashes' do
62+
expect(backtrace_line_in_app_slashes.decorated_path).to eq 'path/to/file/'
63+
end
64+
end
65+
5066
describe '#link_to_source_file' do
5167
it 'adds a link to the source file' do
5268
link = backtrace_line_in_app.link_to_source_file(app) { 'mytext' }

0 commit comments

Comments
 (0)