diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 79a29461ecabd492b3ef3b52b6d21ffe1dbf2069..82f31152c7e212b3e7a4749a5604f325e0518bcc 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -33,7 +33,7 @@ class RequestsController < ApplicationController aspect = current_user.aspect_by_id(params[:request][:aspect_id]) begin - rel_hash = relationship_flow(params[:request][:destination_url]) + rel_hash = relationship_flow(params[:request][:destination_url].strip!) rescue Exception => e raise e unless e.message.include? "not found" flash[:error] = I18n.t 'requests.create.error' diff --git a/app/models/request.rb b/app/models/request.rb index d5747074586b4217b8cebebd309319b4e0c065fd..d910cfaa2d59ea1bcd0bcb419a27ca50c2ed72a4 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -48,6 +48,7 @@ class Request protected def clean_link if self.destination_url + self.destination_url = self.destination_url.strip self.destination_url = 'http://' + self.destination_url unless self.destination_url.match('https?://') self.destination_url = self.destination_url + '/' if self.destination_url[-1,1] != '/' end diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index c40d1a25edef0889c6b86cc58876500ab885d34c..83730f10bacd1612861acb7911a6ff7a0e53ab99 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -38,4 +38,11 @@ describe Request do Request.for_user(user).all.count.should == 1 end + it 'should strip the destination url' do + person_request = Request.new + person_request.destination_url = " http://google.com/ " + person_request.send(:clean_linl) + person_request.destination_url.should == "http://google.com/" + end + end