Use a regex when checking for external urls. It's concise and DRY, less prone to...
authorDaniel Friesen <dantman@users.mediawiki.org>
Fri, 12 Aug 2011 10:20:17 +0000 (10:20 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Fri, 12 Aug 2011 10:20:17 +0000 (10:20 +0000)
resources/mediawiki/mediawiki.js

index 6f9e789..48b024b 100644 (file)
@@ -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( $( '<link/>', {
                                                        rel: 'stylesheet',