Module: Dependabot::Swift::UrlHelpers

Extended by:
T::Sig
Defined in:
lib/dependabot/swift/url_helpers.rb

Overview

Shared URL normalization utilities used by multiple parsers. Produces a canonical dependency name from a git repository URL by stripping the scheme, “www.” prefix, and “.git” suffix.

Class Method Summary collapse

Class Method Details

.normalize_name(source) ⇒ Object



16
17
18
19
20
21
# File 'lib/dependabot/swift/url_helpers.rb', line 16

def self.normalize_name(source)
  uri = URI.parse(source.downcase)
  "#{uri.host}#{uri.path}".delete_prefix("www.").delete_suffix(".git")
rescue URI::InvalidURIError
  source.downcase.delete_suffix(".git")
end