Commit 125f9dc7 authored by allison.browne's avatar allison.browne Committed by Peter Leitzen

Follow up changes to adding cluster Reg-ex

Remove extra un-needed characters from regex and only provide
and move static patterns to constants
parent 92c62ed1
......@@ -16,7 +16,7 @@ module EE
%r{
/clusters
/(?<cluster_id>\d+)
[/]?
/?
}x
)
end
......
......@@ -8,6 +8,10 @@ module Gitlab
class << self
include Gitlab::Utils::StrongMemoize
QUERY_PATTERN = '(?<query>\?[a-zA-Z0-9%.()+_=-]+(&[a-zA-Z0-9%.()+_=-]+)*)?'
ANCHOR_PATTERN = '(?<anchor>\#[a-z0-9_-]+)?'
OPTIONAL_DASH_PATTERN = '(?:/-)?'
# Matches urls for a metrics dashboard. This could be
# either the /metrics endpoint or the /metrics_dashboard
# endpoint.
......@@ -63,10 +67,10 @@ module Gitlab
(?<url>
#{gitlab_host_pattern}
#{project_path_pattern}
(?:/-)?
#{OPTIONAL_DASH_PATTERN}
#{path_suffix_pattern}
#{query_pattern}
#{anchor_pattern}
#{QUERY_PATTERN}
#{ANCHOR_PATTERN}
)
}x
end
......@@ -78,14 +82,6 @@ module Gitlab
def project_path_pattern
"\/#{Project.reference_pattern}"
end
def query_pattern
'(?<query>\?[a-zA-Z0-9%.()+_=-]+(&[a-zA-Z0-9%.()+_=-]+)*)?'
end
def anchor_pattern
'(?<anchor>\#[a-z0-9_-]+)?'
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