diff --git a/unfurler/src/index.ts b/unfurler/src/index.ts index c24cd65af..0bbcb32bc 100644 --- a/unfurler/src/index.ts +++ b/unfurler/src/index.ts @@ -222,7 +222,7 @@ class Server { || rawPath.startsWith('/api/v1/translators/images') || rawPath.startsWith('/resources/profile') ) { - if (req.headers['user-agent'] === 'googlebot') { + if (isSearchCrawler(req.headers['user-agent'])) { if (this.secureHost) { https.get(config.SERVER.HOST + rawPath, { headers: { 'user-agent': 'mempoolunfurl' }}, (got) => got.pipe(res)); } else { @@ -237,7 +237,7 @@ class Server { let result = ''; try { - if (req.headers['user-agent'] === 'googlebot') { + if (isSearchCrawler(req.headers['user-agent'])) { result = await this.renderSEOPage(rawPath); } else { result = await this.renderUnfurlMeta(rawPath); @@ -313,3 +313,7 @@ function capitalize(str) { return str; } } + +function isSearchCrawler(useragent: string): boolean { + return /googlebot/i.test(useragent); +}