This commit is contained in:
syuilo 2018-07-18 07:34:17 +09:00
parent 4727780a3d
commit 4cb51a2d32
2 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import $ from 'cafy';
import Hashtag from '../../../../models/hashtag';
import getParams from '../../get-params';
const escapeRegexp = require('escape-regexp');
export const meta = {
desc: {
@ -38,7 +39,7 @@ export default (params: any) => new Promise(async (res, rej) => {
const hashtags = await Hashtag
.find({
tag: new RegExp(ps.query.toLowerCase())
tag: new RegExp('^' + escapeRegexp(ps.query.toLowerCase()))
}, {
sort: {
count: -1

View File

@ -1,5 +1,6 @@
import $ from 'cafy';
import User, { pack, ILocalUser } from '../../../../models/user';
const escapeRegexp = require('escape-regexp');
/**
* Search a user by username
@ -20,7 +21,7 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
let users = await User
.find({
host: null,
usernameLower: new RegExp(query.toLowerCase())
usernameLower: new RegExp(escapeRegexp(query.toLowerCase()))
}, {
limit: limit,
skip: offset
@ -30,7 +31,7 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
const remoteUsers = await User
.find({
host: { $ne: null },
usernameLower: new RegExp(query.toLowerCase())
usernameLower: new RegExp(escapeRegexp(query.toLowerCase()))
}, {
limit: limit - users.length
});