Skip to content
Snippets Groups Projects
Commit 4cb51a2d authored by syuilo's avatar syuilo
Browse files

Fix bugs

parent 4727780a
No related branches found
No related tags found
No related merge requests found
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
......
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
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment