Module: Dapp::Helper::Url

Included in:
Dapp, Dimg::Config::Directive::GitArtifactRemote
Defined in:
lib/dapp/helper/url.rb

Instance Method Summary collapse

Instance Method Details

#get_host_from_git_url(url) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/dapp/helper/url.rb', line 11

def get_host_from_git_url(url)
  url_without_scheme = url.split("://", 2).last
  url_without_creds = url_without_scheme.split("@", 2).last

  # Split out part after ":" in this kind of url: github.com:flant/dapp.git
  url_part = url_without_creds.split(":", 2).first

  # Split out part after first "/": github.com/flant/dapp.git
  url_part.split("/", 2).first
end

#git_url_to_name(url) ⇒ Object



4
5
6
7
8
9
# File 'lib/dapp/helper/url.rb', line 4

def git_url_to_name(url)
  url_without_scheme = url.split("://", 2).last
  # This may be broken, because "@" should delimit creds, not a ":"
  url_without_creds = url_without_scheme.split(":", 2).last
  url_without_creds.gsub(%r{.*?([^\/ ]+\/[^\/ ]+)\.git}, '\\1')
end