Changeset 36881
- Timestamp:
- 03/08/2016 05:59:45 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r36644 r36881 1688 1688 * On windows systems, replaces backslashes with forward slashes 1689 1689 * and forces upper-case drive letters. 1690 * Ensures that no duplicate slashes exist. 1690 * Allows for two leading slashes for Windows network shares, but 1691 * ensures that all other duplicate slashes are reduced to a single. 1691 1692 * 1692 1693 * @since 3.9.0 1693 1694 * @since 4.4.0 Ensures upper-case drive letters on Windows systems. 1695 * @since 4.5.0 Allows for Windows network shares. 1694 1696 * 1695 1697 * @param string $path Path to normalize. … … 1698 1700 function wp_normalize_path( $path ) { 1699 1701 $path = str_replace( '\\', '/', $path ); 1700 $path = preg_replace( '| /+|','/', $path );1702 $path = preg_replace( '|(?<=.)/+|', '/', $path ); 1701 1703 if ( ':' === substr( $path, 1, 1 ) ) { 1702 1704 $path = ucfirst( $path ); -
trunk/tests/phpunit/tests/file.php
r31937 r36881 176 176 } 177 177 178 /** 179 * @dataProvider data_wp_normalize_path 180 */ 181 function test_wp_normalize_path( $path, $expected ) { 182 $this->assertEquals( $expected, wp_normalize_path( $path ) ); 183 } 184 function data_wp_normalize_path() { 185 return array( 186 // Windows paths 187 array( 'C:\\www\\path\\', 'C:/www/path/' ), 188 array( 'C:\\www\\\\path\\', 'C:/www/path/' ), 189 array( 'c:/www/path', 'C:/www/path' ), 190 array( 'c:\\www\\path\\', 'C:/www/path/' ), // uppercase drive letter 191 array( '\\\\Domain\\DFSRoots\\share\\path\\', '//Domain/DFSRoots/share/path/' ), 192 array( '\\\\Server\\share\\path', '//Server/share/path' ), 193 194 // Linux paths 195 array( '/www/path/', '/www/path/' ), 196 array( '/www/path/////', '/www/path/' ), 197 array( '/www/path', '/www/path' ), 198 ); 199 } 178 200 }
Note: See TracChangeset
for help on using the changeset viewer.