Skip to content

Commit

Permalink
fix: match paths only at start
Browse files Browse the repository at this point in the history
Fixes: #8
  • Loading branch information
Trott committed Feb 1, 2023
1 parent 9ad4f40 commit 30ee13a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.js
Expand Up @@ -45,7 +45,7 @@ const parsePattern = (pattern) => {
.replace(wildCardPattern, '.*')
.replace(EOLPattern, '$');

return new RegExp(regexString, flags);
return new RegExp(`^${regexString}`, flags);
};

const groupMemberRecord = (value) => (
Expand Down
9 changes: 9 additions & 0 deletions test/test-data/can-crawl-test-data.js
Expand Up @@ -60,4 +60,13 @@ module.exports = [{
testPath: '/fish*.php',
matches: ['/fish.php', '/fishheads/catfish.php?parameters'],
nonMatch: ['/Fish.PHP'],
}, {
robots: `
User-agent: *
Disallow: /rss
Allow: /
`,
testPath: '/rss',
matches: ['/home/rssa'],
nonMatch: ['/rss'],
}];

0 comments on commit 30ee13a

Please sign in to comment.