Skip to content

Commit

Permalink
Fix/library subdoamin dappid (#135)
Browse files Browse the repository at this point in the history
* fix: dappid for subdomains (#117)

* fix: subdomain dappid
  • Loading branch information
tomicvladan authored Apr 25, 2023
1 parent 1b7a878 commit e7f5729
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion library/src/utils/dapp.util.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit e7f5729

Please sign in to comment.