Gathering detailed insights and metrics for robots-parser
Gathering detailed insights and metrics for robots-parser
Gathering detailed insights and metrics for robots-parser
Gathering detailed insights and metrics for robots-parser
NodeJS robots.txt parser with support for wildcard (*) matching.
npm install robots-parser
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.8
Supply Chain
100
Quality
75.9
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
157 Stars
90 Commits
20 Forks
5 Watchers
1 Branches
7 Contributors
Updated on Jul 09, 2025
Latest Version
3.0.1
Package Id
robots-parser@3.0.1
Unpacked Size
45.17 kB
Size
9.52 kB
File Count
10
NPM Version
8.19.3
Node Version
16.19.1
Published on
Feb 21, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A robots.txt parser which aims to be complaint with the draft specification.
The parser currently supports:
Via NPM:
npm install robots-parser
or via Yarn:
yarn add robots-parser
1var robotsParser = require('robots-parser');
2
3var robots = robotsParser('http://www.example.com/robots.txt', [
4 'User-agent: *',
5 'Disallow: /dir/',
6 'Disallow: /test.html',
7 'Allow: /dir/test.html',
8 'Allow: /test.html',
9 'Crawl-delay: 1',
10 'Sitemap: http://example.com/sitemap.xml',
11 'Host: example.com'
12].join('\n'));
13
14robots.isAllowed('http://www.example.com/test.html', 'Sams-Bot/1.0'); // true
15robots.isAllowed('http://www.example.com/dir/test.html', 'Sams-Bot/1.0'); // true
16robots.isDisallowed('http://www.example.com/dir/test2.html', 'Sams-Bot/1.0'); // true
17robots.getCrawlDelay('Sams-Bot/1.0'); // 1
18robots.getSitemaps(); // ['http://example.com/sitemap.xml']
19robots.getPreferredHost(); // example.com
boolean or undefined
Returns true if crawling the specified URL is allowed for the specified user-agent.
This will return undefined
if the URL isn't valid for this robots.txt.
boolean or undefined
Returns true if crawling the specified URL is not allowed for the specified user-agent.
This will return undefined
if the URL isn't valid for this robots.txt.
number or undefined
Returns the line number of the matching directive for the specified URL and user-agent if any.
Line numbers start at 1 and go up (1-based indexing).
Returns -1 if there is no matching directive. If a rule is manually added without a lineNumber then this will return undefined for that rule.
number or undefined
Returns the number of seconds the specified user-agent should wait between requests.
Returns undefined if no crawl delay has been specified for this user-agent.
array
Returns an array of sitemap URLs specified by the sitemap:
directive.
string or null
Returns the preferred host name specified by the host:
directive or null if there isn't one.
Fixed bug with https:
URLs defaulting to port 80
instead of 443
if no port is specified.
Thanks to @dskvr for reporting
This affects comparing URLs with the default HTTPs port to URLs without it.
For example, comparing https://example.com/
to https://example.com:443/
or vice versa.
They should be treated as equivalent but weren't due to the incorrect port
being used for https:
.
Fixed bug where if the user-agent passed to isAllowed()
/ isDisallowed()
is called "constructor" it would throw an error.
Added support for relative URLs. This does not affect the default behavior so can safely be upgraded.
Relative matching is only allowed if both the robots.txt URL and the URLs being checked are relative.
For example:
1var robots = robotsParser('/robots.txt', [ 2 'User-agent: *', 3 'Disallow: /dir/', 4 'Disallow: /test.html', 5 'Allow: /dir/test.html', 6 'Allow: /test.html' 7].join('\n')); 8 9robots.isAllowed('/test.html', 'Sams-Bot/1.0'); // false 10robots.isAllowed('/dir/test.html', 'Sams-Bot/1.0'); // true 11robots.isDisallowed('/dir/test2.html', 'Sams-Bot/1.0'); // true
getMatchingLineNumber()
methodThis release is not 100% backwards compatible as it now uses the new URL APIs which are not supported in Node < 7.
The MIT License (MIT)
Copyright (c) 2014 Sam Clarke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
3 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 4/25 approved changesets -- score normalized to 1
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More