Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

robots-txt-guard

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

robots-txt-guard - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

48

lib/patterns.js

@@ -34,32 +34,32 @@ 'use strict';

// strip last character if $
pattern = pattern.replace(/\$$/, '');
if (pattern.includes('*') || pattern.endsWith('$')) {
if (pattern.endsWith('$')) {
pattern = pattern.slice(0, -1);
}
// wildcards are ignored in specificity
const specificityString = pattern.replace(/\*/g, '');
// wildcards are ignored in specificity
const specificityString = pattern.replace(/\*/g, '');
pattern = pattern
.split(/\*+/)
.map(escapeRegExp)
.join('(?:.*)');
pattern = pattern
.split(/\*+/)
.map(escapeRegExp)
.join('(?:.*)');
pattern = '^' + pattern;
if (matchEnd) {
pattern += '$';
}
pattern = '^' + pattern;
if (matchEnd) {
pattern += '$';
}
const regexp = new RegExp(pattern);
const regexp = new RegExp(pattern);
/**
* @param {string} path
* @returns {boolean}
*/
function test (path) {
return regexp.test(path);
return {
specificity: specificityString.length,
test: path => regexp.test(path)
};
} else {
return {
specificity: pattern.length,
test: path => path.startsWith(pattern)
};
}
return {
specificity: specificityString.length,
test: test
};
};

@@ -66,0 +66,0 @@

{
"name": "robots-txt-guard",
"version": "1.0.0",
"version": "1.0.1",
"description": "Validate urls against robots.txt rules.",

@@ -5,0 +5,0 @@ "main": "lib/guard.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc