Commit be41f8e3 authored by Stan Hu's avatar Stan Hu

Merge branch '511-remove-double-slash-from-urls' into 'master'

Remove double slashes from urls generated by PseudonymizationHelper

See merge request gitlab-org/gitlab!81872
parents 2dfdac66 e8820cc1
...@@ -15,7 +15,7 @@ module Routing ...@@ -15,7 +15,7 @@ module Routing
end end
def mask_params def mask_params
return default_root_url + @request.original_fullpath unless has_maskable_params? return @request.original_url unless has_maskable_params?
masked_params = @request.path_parameters.to_h do |key, value| masked_params = @request.path_parameters.to_h do |key, value|
case key case key
...@@ -66,10 +66,6 @@ module Routing ...@@ -66,10 +66,6 @@ module Routing
query_string_hash query_string_hash
end end
def default_root_url
Gitlab::Routing.url_helpers.root_url(only_path: false)
end
end end
def masked_page_url(group:, project:) def masked_page_url(group:, project:)
......
...@@ -222,16 +222,26 @@ RSpec.describe ::Routing::PseudonymizationHelper do ...@@ -222,16 +222,26 @@ RSpec.describe ::Routing::PseudonymizationHelper do
end end
describe 'when url has no params to mask' do describe 'when url has no params to mask' do
let(:root_url) { 'http://localhost/some/path' } let(:original_url) { 'http://localhost/-/security/vulnerabilities' }
let(:request) do
double(:Request,
path_parameters: {
controller: 'security/vulnerabilities',
action: 'index'
},
protocol: 'http',
host: 'localhost',
query_string: '',
original_fullpath: '/-/security/vulnerabilities',
original_url: original_url)
end
context 'returns root url' do before do
before do allow(helper).to receive(:request).and_return(request)
controller.request.path = 'some/path' end
end
it 'masked_page_url' do it 'returns unchanged url' do
expect(subject).to eq(root_url) expect(subject).to eq(original_url)
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment