mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-09-23 02:09:12 +00:00
Use browser native URL instead of mw.Uri
Bug: T374314 Change-Id: I66be10c017e853ea130b0919789b22c4c3f12622
This commit is contained in:
parent
6bf48eee89
commit
475f80cf76
|
@ -124,9 +124,9 @@ function getWprovFromResultIndex( index ) {
|
|||
function addWprovToSearchResultUrls( results, offset ) {
|
||||
return results.map( ( result, index ) => {
|
||||
if ( result.url ) {
|
||||
const uri = new mw.Uri( result.url );
|
||||
uri.query.wprov = getWprovFromResultIndex( index + offset );
|
||||
result = Object.assign( {}, result, { url: uri.toString() } );
|
||||
const url = new URL( result.url, location.href );
|
||||
url.searchParams.set( 'wprov', getWprovFromResultIndex( index + offset ) );
|
||||
result = Object.assign( {}, result, { url: url.toString() } );
|
||||
}
|
||||
return result;
|
||||
} );
|
||||
|
|
|
@ -230,7 +230,7 @@
|
|||
},
|
||||
"skins.vector.search": {
|
||||
"dependencies": [
|
||||
"mediawiki.Uri",
|
||||
"web2017-polyfills",
|
||||
"mediawiki.util",
|
||||
"skins.vector.search.codex.scripts"
|
||||
],
|
||||
|
|
|
@ -13,7 +13,8 @@ describe( 'instrumentation', () => {
|
|||
test( 'addWprovToSearchResultUrls without offset', () => {
|
||||
const url1 = 'https://host/?title=Special%3ASearch&search=Aa',
|
||||
url2Base = 'https://host/?title=Special%3ASearch&search=Ab',
|
||||
url3 = 'https://host/Ac';
|
||||
url3 = 'https://host/Ac',
|
||||
url5 = '/index.php?title=Special%3ASearch&search=Ad';
|
||||
const results = [
|
||||
{
|
||||
title: 'Aa',
|
||||
|
@ -29,6 +30,10 @@ describe( 'instrumentation', () => {
|
|||
},
|
||||
{
|
||||
title: 'Ad'
|
||||
},
|
||||
{
|
||||
title: 'Ae',
|
||||
url: url5
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -48,6 +53,10 @@ describe( 'instrumentation', () => {
|
|||
},
|
||||
{
|
||||
title: 'Ad'
|
||||
},
|
||||
{
|
||||
title: 'Ae',
|
||||
url: `${ location.origin }${ url5 }&wprov=acrw1_4`
|
||||
}
|
||||
] );
|
||||
expect( results[ 0 ].url ).toStrictEqual( url1 );
|
||||
|
|
Loading…
Reference in a new issue