Class: RedirectLegacyProductUrl

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RedirectLegacyProductUrl

Returns a new instance of RedirectLegacyProductUrl.



2
3
4
# File 'lib/redirect_legacy_product_url.rb', line 2

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
# File 'lib/redirect_legacy_product_url.rb', line 6

def call(env)
  if env["PATH_INFO"] =~ %r{/t/.+/p/(.+)}
    return [301, {'Location'=> "/products/#{$1}" }, []]
  end
  @app.call(env)
end