/**
* Get the path to a specified script file, respecting file
* extensions; this is a wrapper around $wgScriptExtension etc.
+ * except for 'index' and 'load' which use $wgScript/$wgLoadScript
*
* @param $script String: script filename, sans extension
* @return String
*/
function wfScript( $script = 'index' ) {
- global $wgScriptPath, $wgScriptExtension;
- return "{$wgScriptPath}/{$script}{$wgScriptExtension}";
+ global $wgScriptPath, $wgScriptExtension, $wgScript, $wgLoadScript;
+ if ( $script === 'index' ) {
+ return $wgScript;
+ } else if ( $script === 'load' ) {
+ return $wgLoadScript;
+ } else {
+ return "{$wgScriptPath}/{$script}{$wgScriptExtension}";
+ }
}
/**
* @return string Address to script (eg. '/w/api.php' )
*/
wikiScript: function ( str ) {
- return mw.config.get( 'wgScriptPath' ) + '/' + ( str || 'index' ) +
- mw.config.get( 'wgScriptExtension' );
+ str = str || 'index';
+ if ( str === 'index' ) {
+ return mw.config.get( 'wgScript' );
+ } else if ( str === 'load' ) {
+ return mw.config.get( 'wgLoadScript' );
+ } else {
+ return mw.config.get( 'wgScriptPath' ) + '/' + str +
+ mw.config.get( 'wgScriptExtension' );
+ }
},
/**
assert.equal( hrefC, '/wiki/Foobar', 'Default title; Get link for current page ("Foobar")' );
});
-QUnit.test( 'wikiScript', 2, function ( assert ) {
+QUnit.test( 'wikiScript', 4, function ( assert ) {
mw.config.set({
- 'wgScript': '/w/index.php',
+ 'wgScript': '/w/i.php', // customized wgScript for bug 39103
+ 'wgLoadScript': '/w/l.php', // customized wgLoadScript for bug 39103
'wgScriptPath': '/w',
'wgScriptExtension': '.php'
});
- assert.equal( mw.util.wikiScript(), mw.config.get( 'wgScript' ), 'Defaults to index.php and is equal to wgScript' );
+ assert.equal( mw.util.wikiScript(), mw.config.get( 'wgScript' ), 'wikiScript() returns wgScript' );
+ assert.equal( mw.util.wikiScript( 'index' ), mw.config.get( 'wgScript' ), "wikiScript( 'index' ) returns wgScript" );
+ assert.equal( mw.util.wikiScript( 'load' ), mw.config.get( 'wgLoadScript' ), "wikiScript( 'load' ) returns wgLoadScript" );
assert.equal( mw.util.wikiScript( 'api' ), '/w/api.php', 'API path' );
});