Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  fix tests using Twig 3.12
  skip tests requiring the intl extension if it's not installed
  🐛 throw ParseException on invalid date
  [ExpressionLanguage] Improve test coverage
  [HttpKernel] [WebProfileBundle] Fix Routing panel for URLs with a colon
  [Form] NumberType: Fix parsing of numbers in exponential notation with negative exponent
  [Security] consistent singular/plural translation in Dutch
  reset the validation context after validating nested constraints
  do not duplicate directory separators
  fix handling empty data in ValueToDuplicatesTransformer
  [Validator] review latvian translations
  [Validator] Add Dutch translation for `WordCount` constraint
  allow more unicode characters in URL paths
  [String][EnglishInflector] Fix words ending in 'le', e.g., articles
  do not duplicate directory separators
  [Uid] Ensure UuidV1 is created in lowercase
  • Loading branch information
derrabus committed Aug 12, 2024
2 parents af29198 + 7f159e1 commit cc9d880
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Iterator/RecursiveDirectoryIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public function current(): SplFileInfo
$subPathname .= $this->directorySeparator;
}
$subPathname .= $this->getFilename();
$basePath = $this->rootPath;

if ('/' !== $basePath = $this->rootPath) {
if ('/' !== $basePath && !str_ends_with($basePath, $this->directorySeparator) && !str_ends_with($basePath, '/')) {
$basePath .= $this->directorySeparator;
}

Expand Down
27 changes: 27 additions & 0 deletions Tests/Iterator/RecursiveDirectoryIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,31 @@ public function testSeekOnFtp()

$this->assertEquals($contains, $actual);
}

public function testTrailingDirectorySeparatorIsStripped()
{
$fixturesDirectory = __DIR__ . '/../Fixtures/';
$actual = [];

foreach (new RecursiveDirectoryIterator($fixturesDirectory, RecursiveDirectoryIterator::SKIP_DOTS) as $file) {
$actual[] = $file->getPathname();
}

sort($actual);

$expected = [
$fixturesDirectory.'.dot',
$fixturesDirectory.'A',
$fixturesDirectory.'copy',
$fixturesDirectory.'dolor.txt',
$fixturesDirectory.'gitignore',
$fixturesDirectory.'ipsum.txt',
$fixturesDirectory.'lorem.txt',
$fixturesDirectory.'one',
$fixturesDirectory.'r+e.gex[c]a(r)s',
$fixturesDirectory.'with space',
];

$this->assertEquals($expected, $actual);
}
}

0 comments on commit cc9d880

Please sign in to comment.