Commit c4ef403ac80204346c4cd7114e38107e6807ae3c

Authored by Nathan Broadbent
1 parent cab56064
Exists in master and in 1 other branch production

Strip any query strings from files

app/models/backtrace_line_normalizer.rb
... ... @@ -12,7 +12,12 @@ class BacktraceLineNormalizer
12 12 if @raw_line['file'].blank?
13 13 "[unknown source]"
14 14 else
15   - @raw_line['file'].to_s.gsub(/\[PROJECT_ROOT\]\/.*\/ruby\/[0-9.]+\/gems/, '[GEM_ROOT]/gems')
  15 + file = @raw_line['file'].to_s
  16 + # Detect lines from gem
  17 + file.gsub!(/\[PROJECT_ROOT\]\/.*\/ruby\/[0-9.]+\/gems/, '[GEM_ROOT]/gems')
  18 + # Strip any query strings
  19 + file.gsub!(/\?[^\?]*$/, '')
  20 + @raw_line['file'] = file
16 21 end
17 22 end
18 23  
... ...
spec/models/backtrace_line_normalizer_spec.rb
... ... @@ -3,16 +3,25 @@ require 'spec_helper'
3 3 describe BacktraceLineNormalizer do
4 4 subject { described_class.new(raw_line).call }
5 5  
6   - describe "sanitize file and method" do
7   - let(:raw_line) { { 'number' => rand(999), 'file' => nil, 'method' => nil } }
  6 + describe "sanitize" do
  7 + context "unknown file and method" do
  8 + let(:raw_line) { { 'number' => rand(999), 'file' => nil, 'method' => nil } }
8 9  
9   - it "should replace nil file with [unknown source]" do
10   - subject['file'].should == "[unknown source]"
11   - end
  10 + it "should replace nil file with [unknown source]" do
  11 + subject['file'].should == "[unknown source]"
  12 + end
12 13  
13   - it "should replace nil method with [unknown method]" do
14   - subject['method'].should == "[unknown method]"
  14 + it "should replace nil method with [unknown method]" do
  15 + subject['method'].should == "[unknown method]"
  16 + end
15 17 end
16 18  
  19 + context "in app file" do
  20 + let(:raw_line) { { 'number' => rand(999), 'file' => "[PROJECT_ROOT]/assets/file.js?body=1", 'method' => nil } }
  21 +
  22 + it "should strip query strings from files" do
  23 + subject['file'].should == "[PROJECT_ROOT]/assets/file.js"
  24 + end
  25 + end
17 26 end
18 27 end
... ...