return Uri;
};
- // inject the current document location, for relative URLs
- mw.Uri = mw.UriRelative( document.location.href );
-
-
+ // if we are running in a browser, inject the current document location, for relative URLs
+ if ( document && document.location && document.location.href ) {
+ mw.Uri = mw.UriRelative( document.location.href );
+ }
} )( jQuery, mediaWiki );
( function() {
+ // ensure we have a generic URI parser if not running in a browser
+ if ( !mw.Uri ) {
+ mw.Uri = mw.UriRelative( 'http://sample.com/' );
+ }
+
describe( "mw.Uri", function() {
describe( "should work well in loose and strict mode", function() {