class Dependabot::Source

def url_with_directory

def url_with_directory
  return url if [nil, ".", "/"].include?(directory)
  case provider
  when "github", "gitlab"
    path = Pathname.new(File.join("tree/#{branch || 'HEAD'}", directory))
                   .cleanpath.to_path
    url + "/" + path
  when "bitbucket"
    path = Pathname.new(File.join("src/#{branch || 'default'}", directory))
                   .cleanpath.to_path
    url + "/" + path
  when "azure"
    url + "?path=#{directory}"
  when "codecommit"
    raise "The codecommit provider does not utilize URLs"
  else raise "Unexpected repo provider '#{provider}'"
  end
end