Class: WhatWeb::Matcher::URL
- Defined in:
- lib/whatweb/matcher/url.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Attributes inherited from Base
Instance Method Summary collapse
- #has_query? ⇒ Boolean
-
#initialize(target, match) ⇒ URL
constructor
A new instance of URL.
- #is_relative? ⇒ Boolean
- #match? ⇒ Boolean
Methods inherited from Base
#compiled_regexp, match?, #search_context
Constructor Details
#initialize(target, match) ⇒ URL
Returns a new instance of URL.
7 8 9 10 |
# File 'lib/whatweb/matcher/url.rb', line 7 def initialize(target, match) super(target, match) @url = match[:url].to_s end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/whatweb/matcher/url.rb', line 6 def url @url end |
Instance Method Details
#has_query? ⇒ Boolean
16 17 18 |
# File 'lib/whatweb/matcher/url.rb', line 16 def has_query? url.match?(/\?/) end |
#is_relative? ⇒ Boolean
12 13 14 |
# File 'lib/whatweb/matcher/url.rb', line 12 def is_relative? url.match?(/^\//) end |
#match? ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/whatweb/matcher/url.rb', line 20 def match? if is_relative? && !has_query? target.uri.path.match? /#{url}$/ elsif is_relative? && has_query? "#{target.uri.path}?#{target.uri.query}".match? /#{url}$/ elsif !is_relative? && has_query? url == "#{target.uri.path}?#{target.uri.query}" else # !is_relative? && !has_query? target.uri.path == url end end |