Ctrl + K
DocumentationLog inGet started

tessl/npm-isbot

tessl install tessl/npm-isbot@5.1.0

Recognise bots/crawlers/spiders using the user agent string.

Agent Success

Agent success rate when using this tile

82%

Improvement

Agent success rate improvement when using this tile compared to baseline

0.94x

Baseline

Agent success rate without this tile

87%

task.mdevals/scenario-6/

Custom Bot Detector Utility

Build utilities that let callers create lightweight bot detectors from custom patterns using the bot-detection dependency.

Capabilities

Detector from regex source

  • createBotDetector accepts a regex string "CrawlerX|TestBot" and returns a detector returning true for "Mozilla/5.0 TestBot/1.0" and false for "Mozilla/5.0 Safari/537.36". @test
  • Passing a RegExp object works the same way, matching the provided pattern against the user agent. @test

Detector from pattern list

  • createDetectorFromList accepts ["FooBot","ScanAPI"] and returns a detector returning true for "ScanAPI Monitor" and false for "Mozilla/5.0 Chrome/114.0". @test

Null-safe detection

  • Any detector returns false when invoked with an empty string, undefined, or null instead of throwing. @test

Implementation

@generates

API

/**
 * Builds a detector from a regex string or RegExp that is evaluated against user agent strings.
 *
 * @param {string|RegExp} patternSource
 * @returns {(userAgent: string | null | undefined) => boolean}
 */
export function createBotDetector(patternSource);

/**
 * Builds a detector from an array of pattern strings that are combined into a regex.
 *
 * @param {string[]} patterns
 * @returns {(userAgent: string | null | undefined) => boolean}
 */
export function createDetectorFromList(patterns);

Dependencies { .dependencies }

isbot { .dependency }

Provides bot detection helpers for compiling custom bot matchers from regex inputs.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/isbot@5.1.x
tile.json