forked from FoundKeyGang/FoundKey
Fix bugs
This commit is contained in:
parent
4727780a3d
commit
4cb51a2d32
2 changed files with 5 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Hashtag from '../../../../models/hashtag';
|
import Hashtag from '../../../../models/hashtag';
|
||||||
import getParams from '../../get-params';
|
import getParams from '../../get-params';
|
||||||
|
const escapeRegexp = require('escape-regexp');
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -38,7 +39,7 @@ export default (params: any) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
const hashtags = await Hashtag
|
const hashtags = await Hashtag
|
||||||
.find({
|
.find({
|
||||||
tag: new RegExp(ps.query.toLowerCase())
|
tag: new RegExp('^' + escapeRegexp(ps.query.toLowerCase()))
|
||||||
}, {
|
}, {
|
||||||
sort: {
|
sort: {
|
||||||
count: -1
|
count: -1
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User, { pack, ILocalUser } from '../../../../models/user';
|
import User, { pack, ILocalUser } from '../../../../models/user';
|
||||||
|
const escapeRegexp = require('escape-regexp');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search a user by username
|
* Search a user by username
|
||||||
|
@ -20,7 +21,7 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
|
||||||
let users = await User
|
let users = await User
|
||||||
.find({
|
.find({
|
||||||
host: null,
|
host: null,
|
||||||
usernameLower: new RegExp(query.toLowerCase())
|
usernameLower: new RegExp(escapeRegexp(query.toLowerCase()))
|
||||||
}, {
|
}, {
|
||||||
limit: limit,
|
limit: limit,
|
||||||
skip: offset
|
skip: offset
|
||||||
|
@ -30,7 +31,7 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
|
||||||
const remoteUsers = await User
|
const remoteUsers = await User
|
||||||
.find({
|
.find({
|
||||||
host: { $ne: null },
|
host: { $ne: null },
|
||||||
usernameLower: new RegExp(query.toLowerCase())
|
usernameLower: new RegExp(escapeRegexp(query.toLowerCase()))
|
||||||
}, {
|
}, {
|
||||||
limit: limit - users.length
|
limit: limit - users.length
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue