jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/336443 )
Change subject: mediawiki.Uri: Don't ignore options param when using default uri ...................................................................... mediawiki.Uri: Don't ignore options param when using default uri Bug: T157035 Change-Id: Iae5edf996e4cd6d1dfbbffd6a915ee55d28409d3 --- M resources/src/mediawiki/mediawiki.Uri.js M tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js 2 files changed, 12 insertions(+), 4 deletions(-) Approvals: Bartosz Dziewoński: Looks good to me, approved jenkins-bot: Verified diff --git a/resources/src/mediawiki/mediawiki.Uri.js b/resources/src/mediawiki/mediawiki.Uri.js index 0c47dbe..95263ec 100644 --- a/resources/src/mediawiki/mediawiki.Uri.js +++ b/resources/src/mediawiki/mediawiki.Uri.js @@ -179,7 +179,8 @@ * override each other (`true`) or automagically convert them to an array (`false`). */ function Uri( uri, options ) { - var prop, + var prop, hrefCur, + hasOptions = ( options !== undefined ), defaultUri = getDefaultUri(); options = typeof options === 'object' ? options : { strictMode: !!options }; @@ -208,8 +209,12 @@ this.query = {}; } } + } else if ( hasOptions ) { + // We didn't get a URI in the constructor, but we got options. + hrefCur = typeof documentLocation === 'string' ? documentLocation : documentLocation(); + this.parse( hrefCur, options ); } else { - // If we didn't get a URI in the constructor, use the default one. + // We didn't get a URI or options in the constructor, use the default instance. return defaultUri.clone(); } diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js index 97185fc..242096e 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js @@ -178,10 +178,10 @@ ); } ); - QUnit.test( 'Constructor( empty )', 4, function ( assert ) { + QUnit.test( 'Constructor( empty[, Object ] )', 5, function ( assert ) { var testuri, MyUri, uri; - testuri = 'http://example.org/w/index.php'; + testuri = 'http://example.org/w/index.php?a=1&a=2'; MyUri = mw.UriRelative( testuri ); uri = new MyUri(); @@ -195,6 +195,9 @@ uri = new MyUri( '' ); assert.equal( uri.toString(), testuri, 'empty string' ); + + uri = new MyUri( null, { overrideKeys: true } ); + assert.deepEqual( uri.query, { a: '2' }, 'null, with options' ); } ); QUnit.test( 'Properties', 8, function ( assert ) { -- To view, visit https://gerrit.wikimedia.org/r/336443 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iae5edf996e4cd6d1dfbbffd6a915ee55d28409d3 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits