📦 EqualifyEverything / equalify

📄 buildUrlSearchClause.ts · 10 lines
1
2
3
4
5
6
7
8
9
10// A search string wrapped in double quotes (e.g. `"https://example.com/"`) matches
// the URL exactly; otherwise it's treated as a partial, substring match.
export const buildUrlSearchClause = (searchString: string) => {
  const quotedMatch = searchString.match(/^"(.*)"$/);
  if (quotedMatch) {
    return { url: { url: { _ilike: quotedMatch[1] } } };
  }
  return { url: { url: { _ilike: `%${searchString}%` } } };
};