4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/commands/utils.rb', line 4
def self.(args)
raise ArgumentError.new('You must specify a URL.') if args.empty?
url = args[0]
url = 'http://' + url unless url.include?('http://') || url.include?('https://')
uri = URI.parse(url)
uri.path = '/' if uri.path == ''
if uri.path[-1, 1] != '/'
uri.path.concat '/'
end
begin
dns = Resolv::DNS.new()
dns.getaddress(uri.host)
rescue => e
raise ArgumentError.new("Invalid URL (#{e.message})") unless uri.host == 'localhost'
end
return uri
end
|