Set parameter only if necessary

pull/73/head
MillenniumEarl 2021-03-03 21:17:23 +01:00
parent dae582eedc
commit 0cb3cdb534
1 changed files with 5 additions and 5 deletions

View File

@ -78,7 +78,7 @@ export default class ThreadSearchQuery implements IQuery {
if (this.onlyTitles) url.searchParams.set("c[title_only]", "1"); if (this.onlyTitles) url.searchParams.set("c[title_only]", "1");
// Add keywords // Add keywords
const encodedKeywords = this.keywords ? encodeURIComponent(this.keywords) : "*"; const encodedKeywords = this.keywords ?? "*";
url.searchParams.set("q", encodedKeywords); url.searchParams.set("q", encodedKeywords);
// Specify the scope of the search (only "threads/post") // Specify the scope of the search (only "threads/post")
@ -99,11 +99,11 @@ export default class ThreadSearchQuery implements IQuery {
// The tags are first joined with a comma, then encoded to URI // The tags are first joined with a comma, then encoded to URI
const includedTags = encodeURIComponent(this.includedTags.join(",")); const includedTags = encodeURIComponent(this.includedTags.join(","));
const excludedTags = encodeURIComponent(this.excludedTags.join(",")); const excludedTags = encodeURIComponent(this.excludedTags.join(","));
url.searchParams.set("c[tags]", includedTags); if (includedTags) url.searchParams.set("c[tags]", includedTags);
url.searchParams.set("c[excludeTags]", excludedTags); if (excludedTags) url.searchParams.set("c[excludeTags]", excludedTags);
// Set minimum reply number // 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 // Add prefixes
const parser = new PrefixParser(); const parser = new PrefixParser();