Skip to content

Commit

Permalink
Regression of the AllowParser, performance not as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
JanPetterMG committed Aug 10, 2016
1 parent b73e7ba commit 17cd7a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/Parser/Directives/AllowParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@ public function add($line)
private function addPath($path)
{
$path = rtrim($path, '*');
if (in_array(mb_substr($path, 0, 1), [
'/',
'*',
])) {
if (!in_array('/', $this->path) &&
in_array(mb_substr($path, 0, 1), [
'/',
'*',
])
) {
$this->path[] = $path;
$this->optimized = false;
}
Expand Down Expand Up @@ -149,9 +151,7 @@ private function removeOverlapping()
foreach ($this->path as $key1 => &$path1) {
foreach ($this->path as $key2 => &$path2) {
if ($key1 !== $key2 &&
(mb_strpos($path1, $path2) === 0 ||
mb_strpos(str_replace('*', '/', $path1), $path2) === 0
)
mb_strpos($path1, $path2) === 0
) {
unset($this->path[$key1]);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/DisallowAllTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public function generateDataForTest()
[
<<<ROBOTS
User-agent: *
Disallow: *test*
Disallow: /admin/
Disallow: /
Disallow: /admin/
Disallow: *test*
ROBOTS
,
<<<RENDERED
Expand Down
3 changes: 2 additions & 1 deletion tests/EndAnchorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function generateDataForTest()
[
<<<ROBOTS
User-Agent: *
Noindex: *$
Noindex: $
Disallow: /*
Allow: /$
Expand All @@ -73,6 +73,7 @@ public function generateDataForTest()
Allow: /$
User-agent: denyme
Disallow: *deny_all/$
Disallow: /deny_all/$
RENDERED
]
Expand Down

0 comments on commit 17cd7a2

Please sign in to comment.