mediawiki.Uri: Fix host example and change foo.com to example.com
authorTimo Tijhof <krinklemail@gmail.com>
Mon, 23 Dec 2013 21:38:01 +0000 (21:38 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Mon, 23 Dec 2013 21:38:01 +0000 (21:38 +0000)
* 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

resources/mediawiki/mediawiki.Uri.js
tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js

index a2d4d6c..98d7e82 100644 (file)
  *
  * 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' } )
index 9913f5e..b6a8a46 100644 (file)
 
                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',