From: Timo Tijhof Date: Mon, 23 Dec 2013 21:38:01 +0000 (+0000) Subject: mediawiki.Uri: Fix host example and change foo.com to example.com X-Git-Tag: 1.31.0-rc.0~17522^2 X-Git-Url: http://git.cyclocoop.org/%22.htmlspecialchars%28%24url_syndic%29.%22?a=commitdiff_plain;h=3bafdea875e4e1316555f247f4c48010b2330f55;p=lhc%2Fweb%2Fwiklou.git mediawiki.Uri: Fix host example and change foo.com to example.com * The example changed host from foo.com to www.foo.com, but the .toString() comment showing the expected value was wrong as it implied setting .host doesn't work, but it does. * Update examples and tests to use example.org or example.com instead of foo, test, or google.com etc. Follows-up a94417720248dd3 which accidentally broke the example, when fixing the .setAttr() -> .attr() mistake. Change-Id: Ifeaf713a8f1db8758b01aa84061b49316ca5d577 --- diff --git a/resources/mediawiki/mediawiki.Uri.js b/resources/mediawiki/mediawiki.Uri.js index a2d4d6cb8d..98d7e823b6 100644 --- a/resources/mediawiki/mediawiki.Uri.js +++ b/resources/mediawiki/mediawiki.Uri.js @@ -12,29 +12,29 @@ * * 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 { @@ -85,7 +85,7 @@ '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' } ) diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js index 9913f5e640..b6a8a46c5e 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js @@ -117,7 +117,7 @@ assert.throws( function () { - return new mw.Uri( 'foo.com/bar/baz', { + return new mw.Uri( 'example.com/bar/baz', { strictMode: true } ); }, @@ -127,10 +127,10 @@ '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 ) { @@ -217,7 +217,7 @@ } ); 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( { @@ -231,7 +231,7 @@ }, { protocol: 'http', - host: 'www.google.com', + host: 'search.example.com', port: undefined, path: '/', query: { q: 'uri' }, @@ -241,7 +241,7 @@ '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',