File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ module Util
66 extend self
77
88 def build_ticketed_url ( url , ticket )
9- return '' if url . empty ?
9+ return '' if url . blank ?
1010 parsed = URI . parse ( url )
1111 query = parsed . query . to_s
1212 params = query . split ( '&' )
@@ -17,14 +17,14 @@ def build_ticketed_url(url, ticket)
1717
1818 PARAM_REGEX = /(?:service|gateway|renew|ticket)=[^&]+/
1919 def clean_service_url ( dirty_url )
20- return '' if dirty_url . empty ?
20+ return '' if dirty_url . blank ?
2121 parsed = URI . parse ( dirty_url )
2222 query = parsed . query . to_s # we really only care about the query portion of the url
2323 query . gsub! ( PARAM_REGEX , '' )
2424 query . gsub! ( /[\/ \? &]$/ , '' )
2525 query . gsub! ( /&&/ , '&' )
2626 query . gsub! ( /^&/ , '' )
27- parsed . query = query . empty ? ? nil : query
27+ parsed . query = query . blank ? ? nil : query
2828 parsed . to_s
2929 end
3030
Original file line number Diff line number Diff line change 2222 it 'must return an empty string when no service url is present' do
2323 expect ( Util . build_ticketed_url ( '' , ticket ) ) . to eq ( '' )
2424 end
25+
26+ it 'must return an empty string when service url is nil' do
27+ expect ( Util . build_ticketed_url ( nil , ticket ) ) . to eq ( '' )
28+ end
2529 end
2630
2731 describe '.clean_service_url' do
2832 it 'must return an empty string when an empty value is passed' do
2933 expect ( Util . clean_service_url ( '' ) ) . to eq ( '' )
3034 end
3135
36+ it 'must return an empty string when an nil value is passed' do
37+ expect ( Util . clean_service_url ( nil ) ) . to eq ( '' )
38+ end
39+
3240 it 'must strip off a trailing ?' do
3341 cleaned = Util . clean_service_url ( 'http://www.google.com?' )
3442 expect ( cleaned ) . to eq ( 'http://www.google.com' )
You can’t perform that action at this time.
0 commit comments