Merge "Fix malformed change weblinks generation" into stable-2.16
This commit is contained in:
@@ -324,14 +324,10 @@
|
||||
if (!weblinks || !weblinks.length) return [];
|
||||
return weblinks.filter(weblink => !this._isDirectCommit(weblink)).map(
|
||||
({name, url}) => {
|
||||
if (url.startsWith('https:') || url.startsWith('http:')) {
|
||||
return {name, url};
|
||||
} else {
|
||||
return {
|
||||
name,
|
||||
url: `../../${url}`,
|
||||
};
|
||||
if (!url.startsWith('https:') && !url.startsWith('http:')) {
|
||||
url = this.getBaseUrl() + (url.startsWith('/') ? '' : '/') + url;
|
||||
}
|
||||
return {name, url};
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -44,6 +44,23 @@ limitations under the License.
|
||||
|
||||
teardown(() => { sandbox.restore(); });
|
||||
|
||||
test('_getChangeWeblinks', () => {
|
||||
sandbox.stub(element, '_isDirectCommit').returns(false);
|
||||
sandbox.stub(element, 'getBaseUrl').returns('base');
|
||||
const link = {name: 'test', url: 'test/url'};
|
||||
const mapLinksToConfig = weblink => ({options: {weblinks: [weblink]}});
|
||||
assert.deepEqual(element._getChangeWeblinks(mapLinksToConfig(link))[0],
|
||||
{name: 'test', url: 'base/test/url'});
|
||||
|
||||
link.url = '/' + link.url;
|
||||
assert.deepEqual(element._getChangeWeblinks(mapLinksToConfig(link))[0],
|
||||
{name: 'test', url: 'base/test/url'});
|
||||
|
||||
link.url = 'https:/' + link.url;
|
||||
assert.deepEqual(element._getChangeWeblinks(mapLinksToConfig(link))[0],
|
||||
{name: 'test', url: 'https://test/url'});
|
||||
});
|
||||
|
||||
test('_getHashFromCanonicalPath', () => {
|
||||
let url = '/foo/bar';
|
||||
let hash = element._getHashFromCanonicalPath(url);
|
||||
|
||||
Reference in New Issue
Block a user