From: Fomafix Date: Mon, 15 Jan 2018 05:17:44 +0000 (+0100) Subject: watch.js: Simplify by using .map() X-Git-Tag: 1.31.0-rc.0~903^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=9a0a597d5dbba138277a415f9fd3d8dea4b7c7b5;p=lhc%2Fweb%2Fwiklou.git watch.js: Simplify by using .map() Change-Id: Idd0b4c67d05e0b300b347f2a3a6890c1f2ec88ad --- diff --git a/resources/src/mediawiki/page/watch.js b/resources/src/mediawiki/page/watch.js index 5b55bb2d72..5b41876dbd 100644 --- a/resources/src/mediawiki/page/watch.js +++ b/resources/src/mediawiki/page/watch.js @@ -79,7 +79,7 @@ * @return {string} The extracted action, defaults to 'view' */ function mwUriGetAction( url ) { - var action, actionPaths, key, i, m, parts; + var action, actionPaths, key, m, parts; // TODO: Does MediaWiki give action path or query param // precedence? If the former, move this to the bottom @@ -92,9 +92,7 @@ for ( key in actionPaths ) { if ( actionPaths.hasOwnProperty( key ) ) { parts = actionPaths[ key ].split( '$1' ); - for ( i = 0; i < parts.length; i++ ) { - parts[ i ] = mw.RegExp.escape( parts[ i ] ); - } + parts = parts.map( mw.RegExp.escape ); m = new RegExp( parts.join( '(.+)' ) ).exec( url ); if ( m && m[ 1 ] ) { return key;