Fix googlebot user-agent detection
This commit is contained in:
parent
2f27d9279d
commit
b1e32ed55f
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user