From e7f5729c062959883e92bc18bd6b87bc935cde00 Mon Sep 17 00:00:00 2001 From: tomicvladan Date: Tue, 25 Apr 2023 16:04:49 +0200 Subject: [PATCH] Fix/library subdoamin dappid (#135) * fix: dappid for subdomains (#117) * fix: subdomain dappid --- library/src/utils/dapp.util.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/src/utils/dapp.util.ts b/library/src/utils/dapp.util.ts index d2e65ba..93cba16 100644 --- a/library/src/utils/dapp.util.ts +++ b/library/src/utils/dapp.util.ts @@ -1,10 +1,15 @@ const dappIdRegex = new RegExp('.+/bzz/([^/]+).*') +const subdomainDappIdRegex = new RegExp('https?://(.+).swarm.localhost:.*') export function getDappId(): string | null { const url = window.location.href // extracts dApp ENS name from a bzz link (e.g http://localhost:1633/bzz/ENS/...) - const result = dappIdRegex.exec(url) + let result = dappIdRegex.exec(url) + + if (!result || !result[1]) { + result = subdomainDappIdRegex.exec(url) + } if (!result || !result[1]) { return null