r24067 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24066‎ | r24067 | r24068 >
Date:18:08, 13 July 2007
Author:brion
Status:old
Tags:
Comment:
Add support for $suffix parameter on wfBasename() clone of basename(), for completeness' sake
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1872,11 +1872,15 @@
18731873 * We'll consider it so always, as we don't want \s in our Unix paths either.
18741874 *
18751875 * @param string $path
 1876+ * @param string $suffix to remove if present
18761877 * @return string
18771878 */
1878 -function wfBaseName( $path ) {
 1879+function wfBaseName( $path, $suffix='' ) {
 1880+ $encSuffix = ($suffix == '')
 1881+ ? ''
 1882+ : ( '(?:' . preg_quote( $suffix, '#' ) . ')?' );
18791883 $matches = array();
1880 - if( preg_match( '#([^/\\\\]*)[/\\\\]*$#', $path, $matches ) ) {
 1884+ if( preg_match( "#([^/\\\\]*?){$encSuffix}[/\\\\]*$#", $path, $matches ) ) {
18811885 return $matches[1];
18821886 } else {
18831887 return '';

Follow-up revisions

RevisionCommit summaryAuthorDate
r24096Merged revisions 23910-24094 via svnmerge from...david22:38, 14 July 2007

Status & tagging log