Sha256: 82deda170f7a41c6197877fa7922b0ceea1a85e92410239bc275bac4636220af
Contents?: true
Size: 619 Bytes
Versions: 1
Compression:
Stored size: 619 Bytes
Contents
module UrlRegexp class Query def initialize @queries = [] end def append(query) return if query.nil? @queries << query.to_s.split('&').reject(&:empty?) end def to_regexp_s common_queries = @queries.reduce { |a, e| a & e } || [] common_queries = common_queries.map { |q| Regexp.quote(q) } if 1 < common_queries.size "\\?(#{common_queries.permutation.map { |qs| "(.*&)?#{qs.join('.*&')}(&.*)?" }.join('|')})" elsif 1 == common_queries.size "\\?(.*&)?#{common_queries.first}(&.*)?" else '(\\?.*)?' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
url_regexp-0.1.2 | lib/url_regexp/query.rb |