1 2 3 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 34 35
|
From: Antonio Terceiro <terceiro@debian.org>
Date: Sun, 5 Apr 2020 17:14:08 -0300
Subject: Reduce warnings under ruby2.7
---
mustermann/lib/mustermann/ast/expander.rb | 2 +-
mustermann/lib/mustermann/ast/translator.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mustermann/lib/mustermann/ast/expander.rb b/mustermann/lib/mustermann/ast/expander.rb
index 1aa495d..75ca3ca 100644
--- a/mustermann/lib/mustermann/ast/expander.rb
+++ b/mustermann/lib/mustermann/ast/expander.rb
@@ -125,7 +125,7 @@ module Mustermann
# @!visibility private
ruby2_keywords def escape(string, *args)
# URI::Parser is pretty slow, let's not send every string to it, even if it's unnecessary
- string =~ /\A\w*\Z/ ? string : super
+ string.is_a?(String) && string =~ /\A\w*\Z/ ? string : super
end
# Turns a sprintf pattern into our secret internal data structure.
diff --git a/mustermann/lib/mustermann/ast/translator.rb b/mustermann/lib/mustermann/ast/translator.rb
index 596e362..983a459 100644
--- a/mustermann/lib/mustermann/ast/translator.rb
+++ b/mustermann/lib/mustermann/ast/translator.rb
@@ -120,7 +120,7 @@ module Mustermann
# @!visibility private
def escape(char, parser: URI::DEFAULT_PARSER, escape: parser.regexp[:UNSAFE], also_escape: nil)
escape = Regexp.union(also_escape, escape) if also_escape
- char =~ escape ? parser.escape(char, Regexp.union(*escape)) : char
+ char.is_a?(String) && char =~ escape ? parser.escape(char, Regexp.union(*escape)) : char
end
end
end
|