strip whitespace from title and notebook in note_params

Ben Cornelis 9 年 前
コミット
21f89e5dc0
共有1 個のファイルを変更した6 個の追加3 個の削除を含む
  1. 6 3
      app/models/agents/evernote_agent.rb

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

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