Commit eaffe45e authored by Piotr Skorupa's avatar Piotr Skorupa

Revert insights page URL masking handler

parent 549c58be
...@@ -31,24 +31,11 @@ module Routing ...@@ -31,24 +31,11 @@ module Routing
end end
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 end
private 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) def mask_id(value)
if @request.path_parameters[:controller] == 'projects/blob' if @request.path_parameters[:controller] == 'projects/blob'
':repository_path' ':repository_path'
...@@ -93,9 +80,7 @@ module Routing ...@@ -93,9 +80,7 @@ module Routing
mask_helper = MaskHelper.new(request, current_group, current_project) mask_helper = MaskHelper.new(request, current_group, current_project)
mask_helper.mask_params mask_helper.mask_params
# We rescue all exception for time being till we test this helper extensively. rescue ActionController::RoutingError, URI::InvalidURIError => e
# Check https://gitlab.com/gitlab-org/gitlab/-/merge_requests/72864#note_711515501
rescue => e # rubocop:disable Style/RescueStandardError
Gitlab::ErrorTracking.track_exception(e, url: request.original_fullpath) Gitlab::ErrorTracking.track_exception(e, url: request.original_fullpath)
nil nil
end end
......
...@@ -20,7 +20,7 @@ RSpec.describe ::Routing::PseudonymizationHelper do ...@@ -20,7 +20,7 @@ RSpec.describe ::Routing::PseudonymizationHelper do
describe 'when url has params to mask' do describe 'when url has params to mask' do
context 'when project/insights page is loaded' 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 let(:request) do
double(:Request, double(:Request,
path_parameters: { path_parameters: {
...@@ -42,7 +42,7 @@ RSpec.describe ::Routing::PseudonymizationHelper do ...@@ -42,7 +42,7 @@ RSpec.describe ::Routing::PseudonymizationHelper do
end end
context 'when groups/insights page is loaded' do 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 let(:request) do
double(:Request, double(:Request,
path_parameters: { path_parameters: {
......
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