Skip to content

Commit 26ae601

Browse files
committed
refactoring: $disallow uses unix directory separator
1 parent 42772b3 commit 26ae601

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/RobotLoader/RobotLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,22 +194,22 @@ private function createFileIterator($dir)
194194
$disallow = [];
195195
foreach ($ignoreDirs as $item) {
196196
if ($item = realpath($item)) {
197-
$disallow[$item] = TRUE;
197+
$disallow[str_replace('\\', '/', $item)] = TRUE;
198198
}
199199
}
200200

201201
$iterator = Nette\Utils\Finder::findFiles(is_array($this->acceptFiles) ? $this->acceptFiles : preg_split('#[,\s]+#', $this->acceptFiles))
202202
->filter(function (SplFileInfo $file) use (&$disallow) {
203-
return !isset($disallow[$file->getPathname()]);
203+
return !isset($disallow[str_replace('\\', '/', $file->getPathname())]);
204204
})
205205
->from($dir)
206206
->exclude($ignoreDirs)
207207
->filter($filter = function (SplFileInfo $dir) use (&$disallow) {
208-
$path = $dir->getPathname();
208+
$path = str_replace('\\', '/', $dir->getPathname());
209209
if (is_file("$path/netterobots.txt")) {
210210
foreach (file("$path/netterobots.txt") as $s) {
211211
if (preg_match('#^(?:disallow\\s*:)?\\s*(\\S+)#i', $s, $matches)) {
212-
$disallow[$path . str_replace('/', DIRECTORY_SEPARATOR, rtrim('/' . ltrim($matches[1], '/'), '/'))] = TRUE;
212+
$disallow[$path . rtrim('/' . ltrim($matches[1], '/'), '/')] = TRUE;
213213
}
214214
}
215215
}

0 commit comments

Comments
 (0)