mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-11 00:22:43 +00:00
remove regex search
This commit is contained in:
@@ -187,7 +187,7 @@ const ArchivePage = createClass({
|
|||||||
placeholder="v3 Reference Document"
|
placeholder="v3 Reference Document"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<small>Tip! you can use <a href="https://regexlearn.com/learn">RegEx</a> if you format your query as <code>/title/</code></small>
|
<small>Tip! you can use <code>-</code> to negate words, and <code>"word"</code> to specify an exact string.</small>
|
||||||
<label>
|
<label>
|
||||||
Results per page
|
Results per page
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -2,21 +2,6 @@ const HomebrewModel = require('./homebrew.model.js').model;
|
|||||||
const router = require('express').Router();
|
const router = require('express').Router();
|
||||||
const asyncHandler = require('express-async-handler');
|
const asyncHandler = require('express-async-handler');
|
||||||
|
|
||||||
const buildTitleConditionsArray = (title) => {
|
|
||||||
if (title.startsWith('/') && title.endsWith('/')) {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
title: {
|
|
||||||
$regex: title.slice(1, -1),
|
|
||||||
$options: 'i',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
return buildTitleConditions(title);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const buildTitleConditions = (inputString) => {
|
const buildTitleConditions = (inputString) => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -80,7 +65,7 @@ const archive = {
|
|||||||
const skip = (page - 1) * pageSize;
|
const skip = (page - 1) * pageSize;
|
||||||
|
|
||||||
const brewsQuery = buildBrewsQuery(req.query.legacy, req.query.v3);
|
const brewsQuery = buildBrewsQuery(req.query.legacy, req.query.v3);
|
||||||
const titleConditionsArray = buildTitleConditionsArray(title);
|
const titleConditionsArray = buildTitleConditions(title);
|
||||||
|
|
||||||
const titleQuery = {
|
const titleQuery = {
|
||||||
$and: [brewsQuery, ...titleConditionsArray],
|
$and: [brewsQuery, ...titleConditionsArray],
|
||||||
@@ -110,7 +95,7 @@ const archive = {
|
|||||||
const title = req.query.title || '';
|
const title = req.query.title || '';
|
||||||
|
|
||||||
const brewsQuery = buildBrewsQuery(req.query.legacy, req.query.v3);
|
const brewsQuery = buildBrewsQuery(req.query.legacy, req.query.v3);
|
||||||
const titleConditionsArray = buildTitleConditionsArray(title);
|
const titleConditionsArray = buildTitleConditions(title);
|
||||||
|
|
||||||
const titleQuery = {
|
const titleQuery = {
|
||||||
$and: [brewsQuery, ...titleConditionsArray],
|
$and: [brewsQuery, ...titleConditionsArray],
|
||||||
|
|||||||
Reference in New Issue
Block a user