lib/support/outbound_hosts.rb in activemerchant-1.47.0 vs lib/support/outbound_hosts.rb in activemerchant-1.48.0
- old
+ new
@@ -1,25 +1,28 @@
require 'uri'
require 'set'
class OutboundHosts
- def self.list
- uris = Set.new
+ def self.list
+ hosts = Set.new
+ invalid_lines = Set.new
Dir['lib/**/*.rb'].each do |file|
content = File.read(file)
content.each_line do |line|
next if line =~ /homepage_url/
-
- if line =~ /("|')(https:\/\/.*)("|')/
- uri = URI.parse($2)
- uris << [uri.host, uri.port]
+
+ if line =~ /("|')(https:\/\/[^'"]*)("|')/
+ begin
+ uri = URI.parse($2)
+ hosts << "#{uri.host}:#{uri.port}"
+ rescue URI::InvalidURIError
+ invalid_lines << line
+ end
end
end
end
- uris.each do |uri|
- puts "#{uri.first} #{uri.last}"
- end
+ [hosts, invalid_lines]
end
-end
\ No newline at end of file
+end