Skip to content

Fix quicklinks search: treat "&" and multilingual "and" equivalents as the same token#425

Open
digitalby wants to merge 1 commit into
raycast:mainfrom
digitalby:fix/quicklinks-search-ampersand-and
Open

Fix quicklinks search: treat "&" and multilingual "and" equivalents as the same token#425
digitalby wants to merge 1 commit into
raycast:mainfrom
digitalby:fix/quicklinks-search-ampersand-and

Conversation

@digitalby
Copy link
Copy Markdown

Fixes #424

Problem

The Quicklinks Explorer search uses name.toLowerCase().includes(search.toLowerCase()). This means & and word equivalents like and, und, oraz, etc. are unrelated strings. A user searching b and h will not find Search B&H, and b&h won't either due to spacing.

Solution

Add a normalizeSearch helper that splits on whitespace and maps any known "and" token to a canonical & before comparison. Both sides of every filter call are normalized the same way.

const AND_TOKENS = new Set(["&", "and", "adn", "und", "oraz", "и", "e", "i"]);

function normalizeSearch(str: string): string {
  return str
    .toLowerCase()
    .split(/\s+/)
    .map((token) => (AND_TOKENS.has(token) ? "&" : token))
    .join(" ")
    .trim();
}

Token-splitting is used instead of regex word boundaries because \b does not work correctly with non-ASCII scripts (e.g. Cyrillic и). AND_TOKENS is a plain Set that can be extended with more languages or typos without touching the comparison logic.

Initial token coverage:

Token Language / Note
and English
adn English typo
und German
oraz Polish
i Polish, Croatian, Swedish
e Italian, Portuguese, Spanish
и Russian, Ukrainian

Testing

  • b and h now matches Search B&H
  • b&h now matches Search B&H
  • b und h now matches Search B&H
  • Searches with no & or "and" tokens are unaffected

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 23, 2026

@digitalby is attempting to deploy a commit to the Raycast Team on Vercel.

A member of the Team first needs to authorize it.

@digitalby
Copy link
Copy Markdown
Author

Bump

@samuelkraft
Copy link
Copy Markdown
Contributor

samuelkraft commented Jun 5, 2026

Thanks for the PR. I agree with the problem, but I don’t think this implementation fixes the main case yet.

With the current normalizer:

normalizeSearch("Search B&H") // "search b&h"
normalizeSearch("b and h")    // "b & h"

So "search b&h".includes("b & h") is still false. Same for b und h.

I’m also worried about mapping single-letter tokens like e and i to &, that would make a search for e stop matching entries like eBay/Etsy.

Could we keep this as a small local helper, centralize the repeated search predicate, and normalize & as a separator before token mapping? Something like:

  const AND_TOKENS = new Set(["and", "adn", "und", "oraz", "и"]);

  function normalizeSearch(value: string) {
    return value
      .toLowerCase()
      .replace(/&/g, " and ")
      .split(/\s+/)
      .map((token) => (AND_TOKENS.has(token) ? "and" : token))
      .join(" ")
      .trim();
  }

That should make b&h, b & h, b and h, and b und h all match Search B&H without changing one-letter searches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quicklinks search: treat "&" and "and" (and multilingual equivalents) as equivalent tokens

2 participants