diff --git a/unfurler/src/index.ts b/unfurler/src/index.ts index 90938a5a8..412dd0f4c 100644 --- a/unfurler/src/index.ts +++ b/unfurler/src/index.ts @@ -27,6 +27,7 @@ class Server { mempoolUrl: URL; network: string; secureHost = true; + canonicalHost: string; constructor() { this.app = express(); @@ -34,6 +35,20 @@ class Server { this.mempoolUrl = new URL(this.mempoolHost); this.secureHost = config.SERVER.HOST.startsWith('https'); this.network = config.MEMPOOL.NETWORK || 'bitcoin'; + + let canonical; + switch(config.MEMPOOL.NETWORK) { + case "liquid": + canonical = "https://liquid.network" + break; + case "bisq": + canonical = "https://bisq.markets" + break; + default: + canonical = "https://mempool.space" + } + this.canonicalHost = canonical; + this.startServer(); } @@ -259,6 +274,8 @@ class Server { let ogImageUrl = config.SERVER.HOST + (matchedRoute.staticImg || matchedRoute.fallbackImg); let ogTitle = 'The Mempool Open Source Project™'; + const canonical = this.canonicalHost + rawPath; + if (matchedRoute.render) { ogImageUrl = `${config.SERVER.HOST}/render/${lang || 'en'}/preview${path}`; ogTitle = `${this.network ? capitalize(this.network) + ' ' : ''}${matchedRoute.networkMode !== 'mainnet' ? capitalize(matchedRoute.networkMode) + ' ' : ''}${matchedRoute.title}`; @@ -269,6 +286,7 @@ class Server {