From: Daniel Friesen Date: Fri, 12 Aug 2011 10:20:17 +0000 (+0000) Subject: Use a regex when checking for external urls. It's concise and DRY, less prone to... X-Git-Tag: 1.31.0-rc.0~28328 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=57c33820a97397ce90932febab26ced25ef2420e;p=lhc%2Fweb%2Fwiklou.git Use a regex when checking for external urls. It's concise and DRY, less prone to bugs like "Whoops I got that hardcoded length int wrong and created a condition that'll never be true",... and it's 4 time faster ;) --- diff --git a/resources/mediawiki/mediawiki.js b/resources/mediawiki/mediawiki.js index 6f9e789719..48b024b745 100644 --- a/resources/mediawiki/mediawiki.js +++ b/resources/mediawiki/mediawiki.js @@ -1071,7 +1071,7 @@ window.mw = window.mediaWiki = new ( function( $ ) { // Allow calling with an external script or single dependency as a string if ( typeof modules === 'string' ) { // Support adding arbitrary external scripts - if ( modules.substr( 0, 7 ) === 'http://' || modules.substr( 0, 8 ) === 'https://' || modules.substr( 0, 2 ) === '//' ) { + if ( /^(https?:)?\/\//.test( modules ) ) { if ( type === 'text/css' ) { $( 'head' ).append( $( '', { rel: 'stylesheet',