UNPKG

express-user-agent-blocker

Version:

Express middleware for blocking access based on User Agent

11 lines (10 loc) 437 B
Object.defineProperty(exports, "__esModule", { value: true }); exports.isBlockUa = void 0; /** * Tests the user agent against the block regex * @param {RegExp} blockRegex - the regex to test against * @param {string} userAgent - the value to test * @return {boolean} true, if UA needs to be blocked, else false */ const isBlockUa = (blockRegex, userAgent) => blockRegex.test(userAgent.toLowerCase()); exports.isBlockUa = isBlockUa;