Module: Spidr::Sanitizers
- Included in:
- Agent
- Defined in:
- lib/spidr/sanitizers.rb
Overview
The Sanitizers module adds methods to Agent which control the sanitation of incoming links.
Instance Attribute Summary collapse
-
#strip_fragments ⇒ Object
Specifies whether the Agent will strip URI fragments.
-
#strip_query ⇒ Object
Specifies whether the Agent will strip URI queries.
Instance Method Summary collapse
-
#initialize_sanitizers(options = {}) ⇒ Object
protected
Initializes the Sanitizer rules.
-
#sanitize_url(url) ⇒ URI::HTTP, URI::HTTPS
Sanitizes a URL based on filtering options.
Instance Attribute Details
#strip_fragments ⇒ Object
Specifies whether the Agent will strip URI fragments
10 11 12 |
# File 'lib/spidr/sanitizers.rb', line 10 def strip_fragments @strip_fragments end |
#strip_query ⇒ Object
Specifies whether the Agent will strip URI queries
13 14 15 |
# File 'lib/spidr/sanitizers.rb', line 13 def strip_query @strip_query end |
Instance Method Details
#initialize_sanitizers(options = {}) ⇒ Object (protected)
Initializes the Sanitizer rules.
51 52 53 54 |
# File 'lib/spidr/sanitizers.rb', line 51 def initialize_sanitizers(={}) @strip_fragments = .fetch(:strip_fragments,true) @strip_query = .fetch(:strip_query,false) end |
#sanitize_url(url) ⇒ URI::HTTP, URI::HTTPS
Sanitizes a URL based on filtering options.
26 27 28 29 30 31 32 33 |
# File 'lib/spidr/sanitizers.rb', line 26 def sanitize_url(url) url = URI(url.to_s) unless url.kind_of?(URI) url.fragment = nil if @strip_fragments url.query = nil if @strip_query return url end |