Explorar el Código

strip whitespace from title and notebook in note_params

Ben Cornelis hace 9 años
padre
commit
21f89e5dc0
Se han modificado 1 ficheros con 6 adiciones y 3 borrados
  1. 6 3
      app/models/agents/evernote_agent.rb

+ 6 - 3
app/models/agents/evernote_agent.rb

@@ -166,7 +166,10 @@ module Agents
     def note_params(options)
       params = interpolated(options)[:note]
       errors.add(:base, "only one notebook allowed") unless params[:notebook].to_s.split(/\s*,\s*/) == 1
+
       params[:tagNames] = params[:tagNames].to_s.split(/\s*,\s*/)
+      params[:title].strip!
+      params[:notebook].strip!
       params
     end
 
@@ -311,9 +314,9 @@ module Agents
           # evernote search grammar:
           # https://dev.evernote.com/doc/articles/search_grammar.php#Search_Terms
           query_terms = []
-          query_terms << "notebook:\"#{opts[:notebook]}\""   if opts[:notebook].present?
-          query_terms << "intitle:\"#{opts[:title]}\""       if opts[:title].present?
-          query_terms << "updated:day-1"                     if opts[:last_checked_at].present?
+          query_terms << "notebook:\"#{opts[:notebook]}\"" if opts[:notebook].present?
+          query_terms << "intitle:\"#{opts[:title]}\""     if opts[:title].present?
+          query_terms << "updated:day-1"                   if opts[:last_checked_at].present?
           opts[:tagNames].to_a.each { |tag| query_terms << "tag:#{tag}" }
 
           filter.words = query_terms.join(" ")