27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
|
|
"use strict";
|
||
|
|
Object.defineProperty(exports, "__esModule", {
|
||
|
|
value: true
|
||
|
|
});
|
||
|
|
exports.isBot = isBot;
|
||
|
|
exports.userAgentFromString = userAgentFromString;
|
||
|
|
exports.userAgent = userAgent;
|
||
|
|
var _uaParserJs = _interopRequireDefault(require("next/dist/compiled/ua-parser-js"));
|
||
|
|
function _interopRequireDefault(obj) {
|
||
|
|
return obj && obj.__esModule ? obj : {
|
||
|
|
default: obj
|
||
|
|
};
|
||
|
|
}
|
||
|
|
function isBot(input) {
|
||
|
|
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(input);
|
||
|
|
}
|
||
|
|
function userAgentFromString(input) {
|
||
|
|
return {
|
||
|
|
...(0, _uaParserJs).default(input),
|
||
|
|
isBot: input === undefined ? false : isBot(input)
|
||
|
|
};
|
||
|
|
}
|
||
|
|
function userAgent({ headers }) {
|
||
|
|
return userAgentFromString(headers.get("user-agent") || undefined);
|
||
|
|
}
|
||
|
|
|
||
|
|
//# sourceMappingURL=user-agent.js.map
|