From ce63c53605b2ddd867ee08267da1adf3a0c2fddb Mon Sep 17 00:00:00 2001 From: Wen-Tien Chang Date: Thu, 28 Jan 2010 17:24:47 +0800 Subject: [PATCH] Add 301 redirect for Link item --- lib/reroute_middleware.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/reroute_middleware.rb b/lib/reroute_middleware.rb index 1e60a7cf..7e39dd4a 100644 --- a/lib/reroute_middleware.rb +++ b/lib/reroute_middleware.rb @@ -13,11 +13,13 @@ class RerouteMiddleware parsed_entry_name = $1 entry = Item.find_by_name( parsed_entry_name ) - - case entry.type - when Component : + + case entry.type.to_s + when 'Component' : env['REQUEST_URI'] = env['REQUEST_URI'].sub!(parsed_entry_name, entry.engine_name) env['QUERY_STRING'] = (env['QUERY_STRING'].blank?)? "entry_name=#{parsed_entry_name}" : "entry_name=#{parsed_entry_name}&#{env['QUERY_STRING']}" + when 'Link' : + return [301, {'Location' => entry.url }, ['See Ya!']] end @app.call(env)