Special-case 'me' values in search queries (#11043)
This commit is contained in:
@@ -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`,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user