Special-case 'me' values in search queries (#11043)

This commit is contained in:
DS Boyce
2026-07-02 09:35:57 -07:00
committed by GitHub
parent 40df0d773a
commit b0a40145e9
6 changed files with 45 additions and 39 deletions
@@ -26,6 +26,23 @@ describe(`extractSearchPostsParams`, () => {
input: `cats to:alice`,
output: {q: `cats`, mentions: `alice`},
},
// `me` is resolved by the backend, so the :me operators stay in q verbatim
// instead of being lifted into author/mentions.
{
name: `keeps from:me in q verbatim`,
input: `cats from:me`,
output: {q: `cats from:me`},
},
{
name: `keeps to:me in q verbatim`,
input: `cats to:me`,
output: {q: `cats to:me`},
},
{
name: `keeps mentions:me in q verbatim`,
input: `cats mentions:me`,
output: {q: `cats mentions:me`},
},
{
name: `accumulates multiple hashtags into tag[]`,
input: `#cats #dogs`,
+8 -2
View File
@@ -106,11 +106,17 @@ export function extractSearchPostsParams(query: string): ExtractedSearchParams {
switch (op) {
case 'from':
result.author ??= value
/*
* `me` is resolved to the viewer by the backend, so leave it in the
* query text verbatim rather than lifting it into a structured param.
*/
if (value === 'me') remaining.push(token)
else result.author ??= value
break
case 'mentions':
case 'to':
result.mentions ??= value
if (value === 'me') remaining.push(token)
else result.mentions ??= value
break
case 'domain':
result.domain ??= value