From 2f9ba14e6a9d7f1ea540687749ded28f69226cba Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Sun, 17 Apr 2022 11:20:28 +0700 Subject: [PATCH] web: Fix incorrect term when using URL mapping --- web/src/giscus.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/web/src/giscus.ts b/web/src/giscus.ts index 84b09be0..874121e5 100644 --- a/web/src/giscus.ts +++ b/web/src/giscus.ts @@ -241,10 +241,16 @@ export class GiscusWidget extends LitElement { return element ? element.content : ''; } + private _getCleanedUrl() { + const url = new URL(location.href); + url.searchParams.delete('giscus'); + return url; + } + private getTerm() { switch (this.mapping) { case 'url': - return origin; + return `${this._getCleanedUrl()}`; case 'title': return document.title; case 'og:title': @@ -266,8 +272,7 @@ export class GiscusWidget extends LitElement { } private getIframeSrc() { - const url = new URL(location.href); - url.searchParams.delete('giscus'); + const url = this._getCleanedUrl(); const origin = `${url}${this.id ? '#' + this.id : ''}`;