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