Class: NormalizeUrl::Normalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/normalize_url/normalizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_uri, options = {}) ⇒ Normalizer

Returns a new instance of Normalizer.



7
8
9
10
# File 'lib/normalize_url/normalizer.rb', line 7

def initialize(original_uri, options={})
  @uri = Addressable::URI.parse(original_uri).normalize
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/normalize_url/normalizer.rb', line 5

def options
  @options
end

#uriObject (readonly)

Returns the value of attribute uri.



5
6
7
# File 'lib/normalize_url/normalizer.rb', line 5

def uri
  @uri
end

Instance Method Details

#normalizeObject



12
13
14
15
16
17
18
# File 'lib/normalize_url/normalizer.rb', line 12

def normalize
  process :remove_trailing_slash
  process :remove_repeating_slashes
  process :remove_hash
  process :sort_query
  uri.to_s
end