lib/invoker/power/url_rewriter.rb in invoker-1.4.1 vs lib/invoker/power/url_rewriter.rb in invoker-1.5.1
- old
+ new
@@ -1,10 +1,8 @@
module Invoker
module Power
class UrlRewriter
- DEV_MATCH_REGEX = [/([\w.-]+)\.dev(\:\d+)?$/, /([\w-]+)\.dev(\:\d+)?$/]
-
def select_backend_config(complete_path)
possible_matches = extract_host_from_domain(complete_path)
exact_match = nil
possible_matches.each do |match|
if match
@@ -15,18 +13,23 @@
exact_match
end
def extract_host_from_domain(complete_path)
matching_strings = []
- DEV_MATCH_REGEX.map do |regexp|
+ tld_match_regex.map do |regexp|
if (match_result = complete_path.match(regexp))
matching_strings << match_result[1]
end
end
matching_strings.uniq
end
private
+
+ def tld_match_regex
+ tld = Invoker.config.tld
+ [/([\w.-]+)\.#{tld}(\:\d+)?$/, /([\w-]+)\.#{tld}(\:\d+)?$/]
+ end
def dns_check(dns_args)
Invoker::IPC::UnixClient.send_command("dns_check", dns_args) do |dns_response|
dns_response
end