22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/puppet_forge_server/utils/url.rb', line 22
def normalize_url(uri_string)
begin
url = URI.parse(uri_string)
rescue URI::InvalidURIError => e
raise PuppetForgeServer::Error::Expected, "Invalid URL '#{uri_string}': #{e.message}"
end
if url.scheme
raise PuppetForgeServer::Error::Expected, "Invalid URL '#{uri_string}': unsupported protocol '#{url.scheme}'" unless url.scheme =~ /^https?$/
else
uri_string = "http://#{uri_string}"
end
uri_string.sub /\/$/, ''
end
|