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
end
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|
case key
......@@ -66,10 +66,6 @@ module Routing
query_string_hash
end
def default_root_url
Gitlab::Routing.url_helpers.root_url(only_path: false)
end
end
def masked_page_url(group:, project:)
......
......@@ -222,16 +222,26 @@ RSpec.describe ::Routing::PseudonymizationHelper do
end
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
controller.request.path = 'some/path'
allow(helper).to receive(:request).and_return(request)
end
it 'masked_page_url' do
expect(subject).to eq(root_url)
end
it 'returns unchanged url' do
expect(subject).to eq(original_url)
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