File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
src/Symfony/Component/Finder Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -70,8 +70,9 @@ public function current()
7070 $ subPathname .= $ this ->directorySeparator ;
7171 }
7272 $ subPathname .= $ this ->getFilename ();
73+ $ basePath = $ this ->rootPath ;
7374
74- if ('/ ' !== $ basePath = $ this ->rootPath ) {
75+ if ('/ ' !== $ basePath && ! str_ends_with ( $ basePath , $ this ->directorySeparator ) ) {
7576 $ basePath .= $ this ->directorySeparator ;
7677 }
7778
Original file line number Diff line number Diff line change @@ -55,4 +55,31 @@ public function testSeekOnFtp()
5555
5656 $ this ->assertEquals ($ contains , $ actual );
5757 }
58+
59+ public function testTrailingDirectorySeparatorIsStripped ()
60+ {
61+ $ fixturesDirectory = __DIR__ . '/../Fixtures/ ' ;
62+ $ actual = [];
63+
64+ foreach (new RecursiveDirectoryIterator ($ fixturesDirectory , RecursiveDirectoryIterator::SKIP_DOTS ) as $ file ) {
65+ $ actual [] = $ file ->getPathname ();
66+ }
67+
68+ sort ($ actual );
69+
70+ $ expected = [
71+ $ fixturesDirectory .'.dot ' ,
72+ $ fixturesDirectory .'A ' ,
73+ $ fixturesDirectory .'copy ' ,
74+ $ fixturesDirectory .'dolor.txt ' ,
75+ $ fixturesDirectory .'gitignore ' ,
76+ $ fixturesDirectory .'ipsum.txt ' ,
77+ $ fixturesDirectory .'lorem.txt ' ,
78+ $ fixturesDirectory .'one ' ,
79+ $ fixturesDirectory .'r+e.gex[c]a(r)s ' ,
80+ $ fixturesDirectory .'with space ' ,
81+ ];
82+
83+ $ this ->assertEquals ($ expected , $ actual );
84+ }
5885}
You can’t perform that action at this time.
0 commit comments