*
* Example:
*
- * var uri = new mw.Uri( 'http://foo.com/mysite/mypage.php?quux=2' );
+ * var uri = new mw.Uri( 'http://example.com/mysite/mypage.php?quux=2' );
*
- * if ( uri.host == 'foo.com' ) {
- * uri.host = 'www.foo.com';
+ * if ( uri.host == 'example.com' ) {
+ * uri.host = 'foo.example.com';
* uri.extend( { bar: 1 } );
*
* $( 'a#id1' ).attr( 'href', uri );
- * // anchor with id 'id1' now links to http://foo.com/mysite/mypage.php?bar=1&quux=2
+ * // anchor with id 'id1' now links to http://foo.example.com/mysite/mypage.php?bar=1&quux=2
*
* $( 'a#id2' ).attr( 'href', uri.clone().extend( { bar: 3, pif: 'paf' } ) );
- * // anchor with id 'id2' now links to http://foo.com/mysite/mypage.php?bar=3&quux=2&pif=paf
+ * // anchor with id 'id2' now links to http://foo.example.com/mysite/mypage.php?bar=3&quux=2&pif=paf
* }
*
* Parsing here is regex based, so may not work on all URIs, but is good enough for most.
*
* Given a URI like
- * 'http://usr:pwd@www.test.com:81/dir/dir.2/index.htm?q1=0&&test1&test2=&test3=value+%28escaped%29&r=1&r=2#top':
+ * 'http://usr:pwd@www.example.com:81/dir/dir.2/index.htm?q1=0&&test1&test2=&test3=value+%28escaped%29&r=1&r=2#top':
* The returned object will have the following properties:
*
* protocol 'http'
* user 'usr'
* password 'pwd'
- * host 'www.test.com'
+ * host 'www.example.com'
* port '81'
* path '/dir/dir.2/index.htm'
* query {
'protocol', // http
'user', // usr
'password', // pwd
- 'host', // www.test.com
+ 'host', // www.example.com
'port', // 81
'path', // /dir/dir.2/index.htm
'query', // q1=0&&test1&test2=value (will become { q1: '0', test1: '', test2: 'value' } )
assert.throws(
function () {
- return new mw.Uri( 'foo.com/bar/baz', {
+ return new mw.Uri( 'example.com/bar/baz', {
strictMode: true
} );
},
'throw error on URI without protocol or // or leading / in strict mode'
);
- uri = new mw.Uri( 'foo.com/bar/baz', {
+ uri = new mw.Uri( 'example.com/bar/baz', {
strictMode: false
} );
- assert.equal( uri.toString(), 'http://foo.com/bar/baz', 'normalize URI without protocol or // in loose mode' );
+ assert.equal( uri.toString(), 'http://example.com/bar/baz', 'normalize URI without protocol or // in loose mode' );
} );
QUnit.test( 'Constructor( Object )', 3, function ( assert ) {
} );
QUnit.test( '.getQueryString()', 2, function ( assert ) {
- var uri = new mw.Uri( 'http://www.google.com/?q=uri' );
+ var uri = new mw.Uri( 'http://search.example.com/?q=uri' );
assert.deepEqual(
{
},
{
protocol: 'http',
- host: 'www.google.com',
+ host: 'search.example.com',
port: undefined,
path: '/',
query: { q: 'uri' },
'basic object properties'
);
- uri = new mw.Uri( 'https://example.org/mw/index.php?title=Sandbox/7&other=Sandbox/7&foo' );
+ uri = new mw.Uri( 'https://example.com/mw/index.php?title=Sandbox/7&other=Sandbox/7&foo' );
assert.equal(
uri.getQueryString(),
'title=Sandbox/7&other=Sandbox%2F7&foo',