Class: MiddleSquid::URI
- Inherits:
-
Addressable::URI
- Object
- Addressable::URI
- MiddleSquid::URI
- Defined in:
- lib/middle_squid/uri.rb
Overview
Provides distinguishable host and path for the blacklists.
Constant Summary collapse
- DOT =
'.'.freeze
- SLASH =
'/'.freeze
Instance Method Summary collapse
Instance Method Details
#cleanhost ⇒ String
10 11 12 13 14 15 16 |
# File 'lib/middle_squid/uri.rb', line 10 def cleanhost clean = normalized_host.force_encoding Encoding::UTF_8 clean.sub! /\Awww\./, '' clean.sub! /\.+\z/, '' clean.insert 0, DOT clean end |
#cleanpath ⇒ String
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/middle_squid/uri.rb', line 19 def cleanpath dirty = normalized_path.force_encoding Encoding::UTF_8 p = Pathname.new(dirty).cleanpath file = p.basename('.*').to_s.downcase p = p.dirname if %w[index default].include? file clean = p.to_s[1..-1] clean << SLASH unless clean.empty? clean end |