Merge branch 'psk-revert-insights-url-masking' into 'master'

Revert insights page URL masking handler

See merge request gitlab-org/gitlab!73764
This commit is contained in:
Mikołaj Wawrzyniak 2021-11-10 11:06:59 +00:00
commit 86093d5c4a
2 changed files with 3 additions and 16 deletions

View file

@ -31,24 +31,11 @@ def mask_params
end
end
generate_url(masked_params.merge(params: masked_query_params))
Gitlab::Routing.url_helpers.url_for(masked_params.merge(params: masked_query_params))
end
private
def generate_url(masked_params)
# The below check is added since `project/insights` route does not
# work with Rails router `url_for` method.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/343551
if @request.path_parameters[:controller] == 'projects/insights'
default_root_url + "#{Gitlab::Routing.url_helpers.namespace_project_insights_path(masked_params)}"
elsif @request.path_parameters[:controller] == 'groups/insights'
default_root_url + "#{Gitlab::Routing.url_helpers.group_insights_path(masked_params)}"
else
Gitlab::Routing.url_helpers.url_for(masked_params)
end
end
def mask_id(value)
if @request.path_parameters[:controller] == 'projects/blob'
':repository_path'

View file

@ -20,7 +20,7 @@
describe 'when url has params to mask' do
context 'when project/insights page is loaded' do
let(:masked_url) { "http://localhost//namespace#{group.id}/project#{project.id}/insights/" }
let(:masked_url) { "http://localhost/namespace#{group.id}/project#{project.id}/insights" }
let(:request) do
double(:Request,
path_parameters: {
@ -42,7 +42,7 @@
end
context 'when groups/insights page is loaded' do
let(:masked_url) { "http://localhost//groups/namespace#{group.id}/-/insights/" }
let(:masked_url) { "http://localhost/groups/namespace#{group.id}/-/insights" }
let(:request) do
double(:Request,
path_parameters: {