`robots-parser` is a JavaScript/TypeScript library designed to parse `robots.txt` files according to the draft specification. As of version 3.0.1, it provides robust support for directives such as `User-agent`, `Allow`, `Disallow`, `Sitemap`, `Crawl-delay`, and `Host`, including advanced features like wildcard (`*`) and end-of-line (`$`) matching for paths. The library maintains an active development status, with recent releases addressing critical bug fixes (e.g., HTTPS URL port handling in 3.0.1) and improving compatibility (e.g., using global URL object in 3.0.0, adding TypeScript definitions in 2.4.0). Its primary differentiator is its adherence to the specification and comprehensive feature set for accurately determining URL crawlability for different user agents, making it a reliable choice for web crawlers and SEO tools.
npm install robots-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a `robots.txt` string, checking URL crawlability for different user-agents, retrieving sitemaps, crawl delays, and preferred host from the parsed rules. It also illustrates how to handle out-of-scope URLs.
Upgrade Node.js to version 10 or higher, or downgrade `robots-parser` to a 2.x release.
Handle `undefined` return values explicitly: `if (result === true) { ... } else if (result === false) { ... } else { /* URL out of scope or invalid */ }`Upgrade to version `3.0.1` or higher to resolve the `https` port default issue.
Upgrade to version `2.3.0` or higher to prevent potential errors with specific user-agent strings.
Check for both `undefined` and `-1` when evaluating the result of `getMatchingLineNumber`.
Upgrade your Node.js environment to version 10.0.0 or higher. Alternatively, downgrade `robots-parser` to a 2.x release if Node.js upgrade is not an option.
Ensure `robotsParser` is called with a valid base URL for the `robots.txt` file and correctly formatted `robots.txt` content (as a string). Verify the content for syntax errors or unexpected structures.
Update `robots-parser` to version `3.0.1` or newer to correctly handle `https` URL port comparisons and ensure accurate permission checks.
No dependency data recorded yet.