Module: Gitlab::Jira::Dvcs
- Defined in:
- lib/gitlab/jira/dvcs.rb
Constant Summary collapse
- ENCODED_SLASH =
'@'
- SLASH =
'/'
- ENCODED_ROUTE_REGEX =
/[a-zA-Z0-9_\-\.#{ENCODED_SLASH}]+/
Class Method Summary collapse
- .decode_slash(path) ⇒ Object
-
.encode_project_name(project) ⇒ Object
To present two types of projects stored by Jira, Type 1 are projects imported prior to nested group support, those project names are not full_path, so they are presented differently to maintain backwards compatibility.
- .encode_slash(path) ⇒ Object
-
.restore_full_path(namespace:, project:) ⇒ Object
To interpret two types of project names stored by Jira (see ‘encode_project_name`).
Class Method Details
.decode_slash(path) ⇒ Object
14 15 16 |
# File 'lib/gitlab/jira/dvcs.rb', line 14 def self.decode_slash(path) path.gsub(ENCODED_SLASH, SLASH) end |
.encode_project_name(project) ⇒ Object
To present two types of projects stored by Jira, Type 1 are projects imported prior to nested group support, those project names are not full_path, so they are presented differently to maintain backwards compatibility. Type 2 are projects imported after nested group support, those project names are encoded full path
26 27 28 29 30 31 32 |
# File 'lib/gitlab/jira/dvcs.rb', line 26 def self.encode_project_name(project) if project.namespace.has_parent? encode_slash(project.full_path) else project.path end end |
.encode_slash(path) ⇒ Object
10 11 12 |
# File 'lib/gitlab/jira/dvcs.rb', line 10 def self.encode_slash(path) path.gsub(SLASH, ENCODED_SLASH) end |
.restore_full_path(namespace:, project:) ⇒ Object
To interpret two types of project names stored by Jira (see ‘encode_project_name`)
39 40 41 42 43 44 45 46 |
# File 'lib/gitlab/jira/dvcs.rb', line 39 def self.restore_full_path(namespace:, project:) if project.include?(ENCODED_SLASH) # Replace multiple slashes with single ones to make sure the redirect stays on the same host project.gsub(ENCODED_SLASH, SLASH).gsub(%r{\/{2,}}, '/') else "#{namespace}/#{project}" end end |