From b5309005e960928bed58c2b94fe9473dde084cb3 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Mon, 19 Jun 2023 05:19:49 +0200 Subject: [PATCH] Using affiliate parameters for Bang, fixed affiliate URL composition on entity page. --- assets/components/entities/entity.vue | 6 ++++-- seeds/06_affiliates.js | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/assets/components/entities/entity.vue b/assets/components/entities/entity.vue index 4007c035..1b5b680a 100755 --- a/assets/components/entities/entity.vue +++ b/assets/components/entities/entity.vue @@ -157,12 +157,14 @@ async function fetchEntity(scroll = true) { const campaign = entity.campaigns.find((campaignX) => !campaignX.banner) || entity.parent?.campaigns.find((campaignX) => !campaignX.banner); + const { searchParams, pathname, origin } = new URL(entity.url); + const affiliateParams = new URLSearchParams({ - ...(entity.url && Object.fromEntries(new URL(entity.url).searchParams)), // preserve any query in entity URL, e.g. ?siteId=5 + ...(entity.url && Object.fromEntries(searchParams)), // preserve any query in entity URL, e.g. ?siteId=5 ...(campaign?.affiliate?.parameters && Object.fromEntries(new URLSearchParams(campaign.affiliate.parameters))), // append affiliate parameters }).toString(); - this.entityUrl = campaign?.url || campaign?.affiliate?.url || `${entity.url}${campaign?.affiliate?.parameters ? `?${affiliateParams}` : ''}`; + this.entityUrl = campaign?.url || campaign?.affiliate?.url || `${origin}${pathname}${campaign?.affiliate?.parameters ? `?${affiliateParams}` : ''}`; this.done = true; if (scroll && this.$refs.filter?.$el) { diff --git a/seeds/06_affiliates.js b/seeds/06_affiliates.js index 6c034976..f8f3973b 100755 --- a/seeds/06_affiliates.js +++ b/seeds/06_affiliates.js @@ -15,6 +15,12 @@ const affiliates = [ parameters: 't=eyJhZmZpbGlhdGUiOiJEZWJhdWNoZXJ5TGliIiwiY2FtcGFpZ24iOiJkZWZhdWx0IiwiYWdldmVyaWZpZWQiOiJ5In0', comment: '50%', }, + { + id: 'bang_signup', + network: 'bang', + parameters: 't=eyJhZmZpbGlhdGUiOiJEZWJhdWNoZXJ5TGliIiwiY2FtcGFpZ24iOiJkZWZhdWx0IiwiYWdldmVyaWZpZWQiOiJ5In0', + comment: '$25 per signup', + }, ]; const bannerTags = { @@ -241,7 +247,7 @@ const campaigns = [ // bang { network: 'bang', - url: 'https://www.bang.com/?aff=eyJ3IjoiMTQ1ODYiLCJsIjoiMzE2NDYiLCJ0IjoiNDU4NjEifQ==', + affiliate: 'bang_signup', comment: 'per signup', }, // julesjordan