Merge "Update formatting"
[lhc/web/wiklou.git] / resources / mediawiki / mediawiki.Title.js
index dde5abf..51770fd 100644 (file)
                        // Trim underscores
                        .replace( rUnderscoreTrim, '' );
 
-               if ( title === '' ) {
-                       return false;
-               }
-
                // Process initial colon
-               if ( title.charAt( 0 ) === ':' ) {
+               if ( title !== '' && title.charAt( 0 ) === ':' ) {
                        // Initial colon means main namespace instead of specified default
                        namespace = NS_MAIN;
                        title = title
                                .replace( rUnderscoreTrim, '' );
                }
 
+               if ( title === '' ) {
+                       return false;
+               }
+
                // Process namespace prefix (if any)
                m = title.match( rSplit );
                if ( m ) {
                                title.indexOf( '../' ) === 0 ||
                                title.indexOf( '/./' ) !== -1 ||
                                title.indexOf( '/../' ) !== -1 ||
-                               title.substr( -2 ) === '/.' ||
-                               title.substr( -3 ) === '/..'
+                               title.substr( title.length - 2 ) === '/.' ||
+                               title.substr( title.length - 3 ) === '/..'
                        )
                ) {
                        return false;
                        thumbPhpRegex = /thumb\.php/,
                        regexes = [
                                // Thumbnails
-                               /\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)\/[^\s\/]+-\1[^\s\/]*$/,
+                               /\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)\/[^\s\/]+-(?:\1|thumbnail)[^\s\/]*$/,
 
                                // Thumbnails in non-hashed upload directories
-                               /\/([^\s\/]+)\/[^\s\/]+-\1[^\s\/]*$/,
+                               /\/([^\s\/]+)\/[^\s\/]+-(?:\1|thumbnail)[^\s\/]*$/,
 
                                // Full size images
                                /\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)$/,
                 * Get the URL to this title
                 *
                 * @see mw.util#getUrl
+                * @param {Object} [params] A mapping of query parameter names to values,
+                *     e.g. `{ action: 'edit' }`.
                 * @return {string}
                 */
-               getUrl: function () {
-                       return mw.util.getUrl( this.toString() );
+               getUrl: function ( params ) {
+                       return mw.util.getUrl( this.toString(), params );
                },
 
                /**