lib/url_regexp/query.rb in url_regexp-0.1.3 vs lib/url_regexp/query.rb in url_regexp-0.1.4
- old
+ new
@@ -16,16 +16,18 @@
end
def to_regexp_s
common_queries = @queries.reduce { |a, e| a & e } || []
common_queries = common_queries.map { |q| Regexp.quote(q) }
- regexp_s = if 1 < common_queries.size
- "\\?(#{common_queries.permutation.map { |qs| "(.*&)?#{qs.join('.*&')}(&.*)?" }.join('|')})"
- elsif 1 == common_queries.size
- "\\?(.*&)?#{common_queries.first}(&.*)?"
+ if 1 <= common_queries.size
+ if 1 == common_queries.size
+ regexp_s = "\\?(.*&)?#{common_queries.first}(&.*)?"
+ else
+ regexp_s = "\\?(#{common_queries.permutation.map { |qs| "(.*&)?#{qs.join('.*&')}(&.*)?" }.join('|')})"
+ end
+ @include_nil ? "(#{regexp_s})?" : regexp_s
else
'(\\?.*)?'
end
- @include_nil ? "(#{regexp_s})?" : regexp_s
end
end
end