Skip to content

Commit

Permalink
strip whitespace from title and notebook in note_params
Browse files Browse the repository at this point in the history
  • Loading branch information
bencornelis committed Sep 20, 2015
1 parent ac6492f commit 21f89e5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/models/agents/evernote_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ def check
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

Expand Down Expand Up @@ -311,9 +314,9 @@ def create_filter
# 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(" ")
Expand Down

0 comments on commit 21f89e5

Please sign in to comment.