2021-06-30 13:44:40 +02:00
import { BLOCKED_PAGES } from '../shared/lib/constants'
2018-11-18 20:44:50 +01:00
2018-12-31 14:44:27 +01:00
export function isBlockedPage ( pathname : string ) : boolean {
2020-04-23 09:38:57 +02:00
return BLOCKED_PAGES . includes ( pathname )
2018-11-18 20:44:50 +01:00
}
2019-03-20 04:53:47 +01:00
export function cleanAmpPath ( pathname : string ) : string {
2019-04-15 11:26:23 +02:00
if ( pathname . match ( /\?amp=(y|yes|true|1)/ ) ) {
2019-11-10 21:44:15 +01:00
pathname = pathname . replace ( /\?amp=(y|yes|true|1)&?/ , '?' )
2019-04-15 11:26:23 +02:00
}
if ( pathname . match ( /&=(y|yes|true|1)/ ) ) {
2019-11-10 21:44:15 +01:00
pathname = pathname . replace ( /&=(y|yes|true|1)/ , '' )
2019-04-15 11:26:23 +02:00
}
pathname = pathname . replace ( /\?$/ , '' )
return pathname
2019-03-20 04:53:47 +01:00
}
2021-09-08 00:34:21 +02:00
export function isBot ( userAgent : string ) : boolean {
2021-11-17 04:49:37 +01:00
return /Googlebot|Mediapartners-Google|AdsBot-Google|googleweblight|Storebot-Google|Google-PageRenderer|Bingbot|BingPreview|Slurp|DuckDuckBot|baiduspider|yandex|sogou|LinkedInBot|bitlybot|tumblr|vkShare|quora link preview|facebookexternalhit|facebookcatalog|Twitterbot|applebot|redditbot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|ia_archiver/i . test (
2021-09-08 00:34:21 +02:00
userAgent
)
}
2022-01-20 22:25:44 +01:00
export function isTargetLikeServerless ( target : string ) {
const isServerless = target === 'serverless'
const isServerlessTrace = target === 'experimental-serverless-trace'
return isServerless || isServerlessTrace
}