From 4c2a50c6af8973512381155c6b7ed06c9e789b95 Mon Sep 17 00:00:00 2001 From: Guilherme Pimenta Date: Wed, 26 Jun 2024 19:08:53 -0300 Subject: [PATCH] only one of the category fields should nbe set --- README.md | 10 +++++++--- src/index.ts | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 17259be..517f180 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,16 @@ Directly from unpkg.com | width | Number | Banner width | | height | Number | Banner height | | id | String | The slot ID for this banner | -| category-id | Optional String | The category ID of the current page | -| category-ids | Optional String | Comma (,) separated list of category IDs, the item must match all | -| category-disjunctions | Optional String | Comma (,) separated list of category IDs, the item must match any | +| category-id* | Optional String | The category ID of the current page | +| category-ids* | Optional String | Comma (,) separated list of category IDs, the item must match all | +| category-disjunctions* | Optional String | Comma (,) separated list of category IDs, the item must match any | | search-query | Optional String | The search query of the current page | | location | Optional String | The location for geotargeting | +\* Only one of `[category-id, category-ids, category-disjunctions]` must be set. + +If multiple are set, only the first will be considered, in that order. + # Banner Behaviors | Function Name | Arg type | Return Type | Description | diff --git a/src/index.ts b/src/index.ts index 700d6c5..37100d7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -208,11 +208,11 @@ export class TopsortBanner extends LitElement { }; } else if (this.categoryIds) { auction.category = { - ids: this.categoryIds.split(","), + ids: this.categoryIds.split(",").map((item) => item.trim()), }; } else if (this.categoryDisjunctions) { auction.category = { - disjunctions: this.categoryDisjunctions.split(","), + disjunctions: this.categoryDisjunctions.split(",").map((item) => item.trim()), }; } else if (this.searchQuery) { auction.searchQuery = this.searchQuery;