From 0aeab944bf814f81555f4369e4acc8249844c741 Mon Sep 17 00:00:00 2001 From: Gonzalo Rodriguez Date: Sat, 3 Sep 2011 00:16:03 -0300 Subject: [PATCH] Related to #1885. Workaround to avoid crashing when searching tags with dots like cubbi.es What i did was to redirect to the tag without dots, in this case cubbies I didn't consider a good idea to add route support for /tags/cubbi.es since it get messed with request formats --- app/controllers/people_controller.rb | 2 +- spec/controllers/people_controller_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 572b3ebe0..e89ecb387 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -18,7 +18,7 @@ class PeopleController < ApplicationController params[:q] ||= params[:term] || '' if (params[:q][0] == 35 || params[:q][0] == '#') && params[:q].length > 1 - redirect_to tag_path(:name => params[:q].gsub("#", "")) + redirect_to tag_path(:name => params[:q].gsub(/[#\.]/, '')) return end diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 09a670712..598b0e63d 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -72,6 +72,11 @@ describe PeopleController do get :index, :q => '#babies' response.should redirect_to('/tags/babies') end + + it 'goes to a tag page if you search for a hash with dots' do + get :index, :q => '#babi.es' + response.should redirect_to('/tags/babies') + end end describe '#tag_index' do