Skip to content

Commit

Permalink
match? is ruby 2.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
godfat committed Jul 14, 2018
1 parent a83e741 commit 30d16b0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/jellyfish/urlmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class URLMap
def initialize mapped_not_chomped
mapped = transform_keys(mapped_not_chomped){ |k| k.sub(%r{/+\z}, '') }
keys = mapped.keys
@no_host = !keys.any?{ |k| k.match?(%r{\Ahttps?://}) }
@no_host = !keys.any?{ |k| match?(k, %r{\Ahttps?://}) }

string = keys.sort_by{ |k| -k.size }.
map{ |k| build_regexp(k) }.
Expand Down Expand Up @@ -79,5 +79,13 @@ def transform_keys hash, &block
end
end
end

def match? string, regexp
if string.respond_to?(:match?)
string.match?(regexp)
else
string =~ regexp
end
end
end
end

0 comments on commit 30d16b0

Please sign in to comment.