From ea4d60fe1e5d7ecde986ad11efe61aba14451a7b Mon Sep 17 00:00:00 2001 From: Fishbakh-N Date: Mon, 19 Aug 2024 14:46:37 +0300 Subject: [PATCH] accept theme color with and without hash --- packages/donate-button-v4/src/helpers/parseDonateUrl.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/donate-button-v4/src/helpers/parseDonateUrl.ts b/packages/donate-button-v4/src/helpers/parseDonateUrl.ts index cc6284f1..2fc08580 100644 --- a/packages/donate-button-v4/src/helpers/parseDonateUrl.ts +++ b/packages/donate-button-v4/src/helpers/parseDonateUrl.ts @@ -87,8 +87,13 @@ export function parseDonateUrl( const minAmount = intFromString( searchParameters.get(DonateUrlParameters.MIN_AMOUNT) ); - const primaryColor = + const primaryColorFromUrl = searchParameters.get(DonateUrlParameters.THEME_COLOR) ?? undefined; + const primaryColor = primaryColorFromUrl + ? primaryColorFromUrl.startsWith('#') + ? primaryColorFromUrl + : `#${primaryColorFromUrl}` + : undefined; if (!nonprofitSlug) { return;