Class: Pakyow::Actions::Normalizer

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

Overview

Normalizes request uris, issuing a 301 redirect to the normalized uri.

Instance Method Summary collapse

Instance Method Details

#call(connection) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/pakyow/actions/normalizer.rb', line 12

def call(connection)
  if strict_www? && require_www? && !www?(connection) && !subdomain?(connection)
    redirect!(connection, File.join(add_www(connection), connection.fullpath))
  elsif strict_www? && !require_www? && www?(connection)
    redirect!(connection, File.join(remove_www(connection), connection.fullpath))
  elsif strict_path? && slash?(connection)
    redirect!(connection, String.normalize_path(connection.fullpath))
  end
end