Easy fix: search only works with ASCII characters

Open Beginner friendly
#491 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
ruby
Domain
backend, search

Research direction

In searchable.rb, start with remove_invalid_search_characters and quote_query_tokens, where the ASCII-only word patterns are identified. Update the character handling so searches retain extended Latin, Greek, Cyrillic, and other non-ASCII letters, then verify that quoted and unquoted searches work with those characters.

Written by the indexing model from the issue text.

Description

Ruby’s \w is basically [a-zA-Z0-9_] which is useless for many languages.

Thus the following code ↓ inside searchable.rb means search won’t work for extended latin, greek, cyrillic, what have you

        def remove_invalid_search_characters(terms)
          terms.gsub(/[^\w"]/, " ") // ***********************←
        end

        def quote_query_tokens(terms)
          terms.scan(/"[^"]*"|\w+/) // ***********************←
            .filter_map { |token| token.delete('"').presence }
            .map { |token| %("#{token}") }
            .join(" ")
        end

Replace it with [[:word:]] and this should fix it according to the benevolent AI (I don’t know shit about RoR)

Image
Dominant language
Ruby
Stars
551
Forks
94
Avg merge
2d 14h
Merged PRs (30d)
7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from basecamp/writebook

All issues in basecamp/writebook

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.