Class: WhatWeb::Matcher::URL
- Inherits:
-
Base
show all
- Defined in:
- lib/whatweb/matcher/url.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#match, #target
Instance Method Summary
collapse
Methods inherited from Base
#compiled_regexp, match?, #search_context
Constructor Details
#initialize(target, match) ⇒ 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
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
target.uri.path == url
end
end
|