diff --git a/app/browse.rb b/app/browse.rb index f909e1b8..f3f64097 100644 --- a/app/browse.rb +++ b/app/browse.rb @@ -1,5 +1,5 @@ get '/browse/?' do - params.delete 'tag' if params[:tag].nil? || params[:tag].empty? + params.delete 'tag' if params[:tag].nil? || params[:tag].strip.empty? site_dataset = browse_sites_dataset site_dataset = site_dataset.paginate @current_page, Site::BROWSE_PAGINATION_LENGTH @page_count = site_dataset.page_count || 1 @@ -65,4 +65,4 @@ def browse_sites_dataset end site_dataset -end \ No newline at end of file +end diff --git a/app/contact.rb b/app/contact.rb index 69c178a7..0b0726b5 100644 --- a/app/contact.rb +++ b/app/contact.rb @@ -27,4 +27,4 @@ post '/contact' do flash[:success] = 'Your contact has been sent.' redirect '/' end -end \ No newline at end of file +end diff --git a/app/password_reset.rb b/app/password_reset.rb index e8a361e8..9fd20299 100644 --- a/app/password_reset.rb +++ b/app/password_reset.rb @@ -41,7 +41,7 @@ the Neocities Cat end get '/password_reset_confirm' do - if params[:token].nil? || params[:token].empty? + if params[:token].nil? || params[:token].strip.empty? flash[:error] = 'Could not find a site with this token.' redirect '/' end @@ -67,4 +67,4 @@ get '/password_reset_confirm' do end redirect '/' -end \ No newline at end of file +end diff --git a/app/site_files.rb b/app/site_files.rb index ef6a02fa..3ae202e4 100644 --- a/app/site_files.rb +++ b/app/site_files.rb @@ -16,7 +16,7 @@ post '/site_files/create_page' do params[:pagefilename].gsub!(/[^a-zA-Z0-9_\-.]/, '') params[:pagefilename].gsub!(/\.html$/i, '') - if params[:pagefilename].nil? || params[:pagefilename].empty? + if params[:pagefilename].nil? || params[:pagefilename].strip.empty? @errors << 'You must provide a file name.' halt erb(:'site_files/new_page') end diff --git a/app/surf.rb b/app/surf.rb index 123c2d88..f4639c5c 100644 --- a/app/surf.rb +++ b/app/surf.rb @@ -1,5 +1,5 @@ get '/surf/?' do - params.delete 'tag' if params[:tag].nil? || params[:tag].empty? + params.delete 'tag' if params[:tag].nil? || params[:tag].strip.empty? site_dataset = browse_sites_dataset site_dataset = site_dataset.paginate @current_page, 1 @page_count = site_dataset.page_count || 1 @@ -14,4 +14,4 @@ get '/surf/:username' do |username| @title = @site.title not_found if @site.nil? erb :'surf', layout: false -end \ No newline at end of file +end diff --git a/ext/string.rb b/ext/string.rb index ed56207c..12ec0af1 100644 --- a/ext/string.rb +++ b/ext/string.rb @@ -1,8 +1,4 @@ class String - def empty? - strip == '' ? true : false - end - def shorten(length, usedots=true) if usedots return self if self.length < length @@ -15,4 +11,4 @@ class String def unindent gsub /^#{scan(/^\s*/).min_by{|l|l.length}}/, "" end -end \ No newline at end of file +end