From 0cb3cdb5343ca65485b583879547a2fa7f62378f Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Wed, 3 Mar 2021 21:17:23 +0100 Subject: [PATCH] Set parameter only if necessary --- src/scripts/classes/query/thread-search-query.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/scripts/classes/query/thread-search-query.ts b/src/scripts/classes/query/thread-search-query.ts index 9468675..824f8b9 100644 --- a/src/scripts/classes/query/thread-search-query.ts +++ b/src/scripts/classes/query/thread-search-query.ts @@ -78,9 +78,9 @@ export default class ThreadSearchQuery implements IQuery { if (this.onlyTitles) url.searchParams.set("c[title_only]", "1"); // Add keywords - const encodedKeywords = this.keywords ? encodeURIComponent(this.keywords) : "*"; + const encodedKeywords = this.keywords ?? "*"; url.searchParams.set("q", encodedKeywords); - + // Specify the scope of the search (only "threads/post") url.searchParams.set("t", "post"); @@ -99,11 +99,11 @@ export default class ThreadSearchQuery implements IQuery { // The tags are first joined with a comma, then encoded to URI const includedTags = encodeURIComponent(this.includedTags.join(",")); const excludedTags = encodeURIComponent(this.excludedTags.join(",")); - url.searchParams.set("c[tags]", includedTags); - url.searchParams.set("c[excludeTags]", excludedTags); + if (includedTags) url.searchParams.set("c[tags]", includedTags); + if (excludedTags) url.searchParams.set("c[excludeTags]", excludedTags); // Set minimum reply number - url.searchParams.set("c[min_reply_count]", this.minimumReplies.toString()); + if (this.minimumReplies > 0) url.searchParams.set("c[min_reply_count]", this.minimumReplies.toString()); // Add prefixes const parser = new PrefixParser();