From 6604d3b5c3aa0a9d500d607bd2f90544b91c0dab Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Tue, 16 Feb 2021 15:16:20 +0100 Subject: [PATCH] Add support for literal tags and prefixes --- src/scripts/classes/search-query.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/scripts/classes/search-query.ts b/src/scripts/classes/search-query.ts index 3543281..46ecc55 100644 --- a/src/scripts/classes/search-query.ts +++ b/src/scripts/classes/search-query.ts @@ -3,6 +3,7 @@ import validator from 'class-validator'; // Modules from file import { urls } from "../constants/url.js"; +import PrefixParser from './prefix-parser.js'; /** * Query used to search for specific threads on the platform. @@ -37,14 +38,14 @@ export default class SearchQuery { @validator.ArrayMaxSize(SearchQuery.MAX_TAGS, { message: "Too many tags: $value instead of $constraint1" }) - public tags: number[] = []; + public tags: string[] = []; /** * List of IDs of prefixes to be included in the search. */ @validator.IsArray({ message: "Expected an array, received $value" }) - public prefixes: number[] = []; + public prefixes: string[] = []; /** * Sorting type between (default: `date`): * `date`, `likes`, `views`, `title`, `rating` @@ -104,11 +105,12 @@ export default class SearchQuery { url.searchParams.set("cat", this.category); // Add tags and prefixes - for (const tag of this.tags) { + const parser = new PrefixParser(); + for (const tag of parser.prefixesToIDs(this.tags)) { url.searchParams.append("tags[]", tag.toString()); } - for (const p of this.prefixes) { + for (const p of parser.prefixesToIDs(this.prefixes)) { url.searchParams.append("prefixes[]", p.toString()); }