Merge "Fix malformed UTF-8 going to query profiler"
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.js
index 0d57d59..4516e20 100644 (file)
                                                        for ( i = 0; i < modules.length; i += 1 ) {
                                                                // Determine how many bytes this module would add to the query string
                                                                lastDotIndex = modules[i].lastIndexOf( '.' );
-                                                               // Note that these substr() calls work even if lastDotIndex == -1
+
+                                                               // If lastDotIndex is -1, substr() returns an empty string
                                                                prefix = modules[i].substr( 0, lastDotIndex );
-                                                               suffix = modules[i].substr( lastDotIndex + 1 );
+                                                               suffix = modules[i].slice( lastDotIndex + 1 );
+
                                                                bytesAdded = moduleMap[prefix] !== undefined
                                                                        ? suffix.length + 3 // '%2C'.length == 3
                                                                        : modules[i].length + 3; // '%7C'.length == 3
                                                }
 
                                                for ( key in mw.loader.store.items ) {
-                                                       module = key.substring( 0, key.indexOf( '@' ) );
+                                                       module = key.slice( 0, key.indexOf( '@' ) );
                                                        if ( mw.loader.store.getModuleKey( module ) !== key ) {
                                                                mw.loader.store.stats.expired++;
                                                                delete mw.loader.store.items[key];