Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -1872,11 +1872,15 @@ |
1873 | 1873 | * We'll consider it so always, as we don't want \s in our Unix paths either. |
1874 | 1874 | * |
1875 | 1875 | * @param string $path |
| 1876 | + * @param string $suffix to remove if present |
1876 | 1877 | * @return string |
1877 | 1878 | */ |
1878 | | -function wfBaseName( $path ) { |
| 1879 | +function wfBaseName( $path, $suffix='' ) { |
| 1880 | + $encSuffix = ($suffix == '') |
| 1881 | + ? '' |
| 1882 | + : ( '(?:' . preg_quote( $suffix, '#' ) . ')?' ); |
1879 | 1883 | $matches = array(); |
1880 | | - if( preg_match( '#([^/\\\\]*)[/\\\\]*$#', $path, $matches ) ) { |
| 1884 | + if( preg_match( "#([^/\\\\]*?){$encSuffix}[/\\\\]*$#", $path, $matches ) ) { |
1881 | 1885 | return $matches[1]; |
1882 | 1886 | } else { |
1883 | 1887 | return ''; |