Class: Spree::Core::Middleware::RedirectLegacyProductUrl

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RedirectLegacyProductUrl

Returns a new instance of RedirectLegacyProductUrl.



5
6
7
# File 'lib/spree/core/middleware/redirect_legacy_product_url.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
# File 'lib/spree/core/middleware/redirect_legacy_product_url.rb', line 9

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