robots-txt-parser icon indicating copy to clipboard operation
robots-txt-parser copied to clipboard

Wrong boolean value in RobotsTxtValidator.php?

Open scott8035 opened this issue 1 year ago • 1 comments

In https://github.com/bopoda/robots-txt-parser/blob/master/src/RobotsTxtParser/RobotsTxtValidator.php, there's a chunk of code at line 47:

        $hasAllowDirectives = true;
        foreach ($orderedDirectives as $directiveRow) {
            if ($directiveRow['directive'] == 'allow') {
                $hasAllowDirectives = true;
                break;
            }
        }

Shouldn't that be:

        $hasAllowDirectives = **false**;
        foreach ($orderedDirectives as $directiveRow) {
            if ($directiveRow['directive'] == 'allow') {
                $hasAllowDirectives = true;
                break;
            }
        }

scott8035 avatar Sep 10 '23 17:09 scott8035

Yes, you are right @scott8035 . The initial intention was as in code you provided. In general it should work, but extra condition does not give profit. Will have a look at this class later to improve.

bopoda avatar Jan 11 '24 07:01 bopoda