From 7cf4aa9f110cebf1bf3017471b8e96d2522ad462 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 23 Dec 2017 04:38:56 +0900 Subject: #1034 --- src/api/endpoints/posts/search.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/api/endpoints/posts') diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts index 6cea5bdf53..26675989dd 100644 --- a/src/api/endpoints/posts/search.ts +++ b/src/api/endpoints/posts/search.ts @@ -97,14 +97,22 @@ async function byNative(res, rej, me, text, userId, following, mute, reply, repo const push = x => q.$and.push(x); if (text) { - push({ - $and: text.split(' ').map(x => ({ - // キーワードが-で始まる場合そのキーワードを除外する - text: x[0] == '-' ? { - $not: new RegExp(escapeRegexp(x.substr(1))) - } : new RegExp(escapeRegexp(x)) - })) - }); + // 完全一致検索 + if (/"""(.+?)"""/.test(text)) { + const x = text.match(/"""(.+?)"""/)[1]; + push({ + text: x + }); + } else { + push({ + $and: text.split(' ').map(x => ({ + // キーワードが-で始まる場合そのキーワードを除外する + text: x[0] == '-' ? { + $not: new RegExp(escapeRegexp(x.substr(1))) + } : new RegExp(escapeRegexp(x)) + })) + }); + } } if (userId) { -- cgit v1.2.3-freya