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 ...@@ -16,7 +16,7 @@ module EE
%r{ %r{
/clusters /clusters
/(?<cluster_id>\d+) /(?<cluster_id>\d+)
[/]? /?
}x }x
) )
end end
......
...@@ -8,6 +8,10 @@ module Gitlab ...@@ -8,6 +8,10 @@ module Gitlab
class << self class << self
include Gitlab::Utils::StrongMemoize 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 # Matches urls for a metrics dashboard. This could be
# either the /metrics endpoint or the /metrics_dashboard # either the /metrics endpoint or the /metrics_dashboard
# endpoint. # endpoint.
...@@ -63,10 +67,10 @@ module Gitlab ...@@ -63,10 +67,10 @@ module Gitlab
(?<url> (?<url>
#{gitlab_host_pattern} #{gitlab_host_pattern}
#{project_path_pattern} #{project_path_pattern}
(?:/-)? #{OPTIONAL_DASH_PATTERN}
#{path_suffix_pattern} #{path_suffix_pattern}
#{query_pattern} #{QUERY_PATTERN}
#{anchor_pattern} #{ANCHOR_PATTERN}
) )
}x }x
end end
...@@ -78,14 +82,6 @@ module Gitlab ...@@ -78,14 +82,6 @@ module Gitlab
def project_path_pattern def project_path_pattern
"\/#{Project.reference_pattern}" "\/#{Project.reference_pattern}"
end 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 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