2022-11-01 12:33:17 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module GitUrl
|
|
|
|
class << self
|
|
|
|
SSH_REGEXP = /(\w+@(\w+\.)*\w+):(.*)/
|
|
|
|
|
|
|
|
def normalize(url)
|
|
|
|
if m = SSH_REGEXP.match(url)
|
|
|
|
url = "ssh://#{m[1]}/#{m[3]}"
|
|
|
|
end
|
|
|
|
|
|
|
|
if url.start_with?("https://github.com/") && !url.end_with?(".git")
|
2023-01-20 13:52:49 -05:00
|
|
|
url = url.gsub(%r{/\z}, "")
|
2022-11-01 12:33:17 -04:00
|
|
|
url += ".git"
|
|
|
|
end
|
|
|
|
|
|
|
|
url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|