Merge branch 'stable-3.7' into stable-3.8 * stable-3.7: Remove extra base URL prefix in gr-copy-links Release-Notes: skip Change-Id: I57cb5184deb3e87eb4eb36228b420b3ad609f6e3
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts index abd3ff0..fc8bcb9 100644 --- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts +++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
@@ -140,7 +140,7 @@ import {FilesExpandedState} from '../gr-file-list-constants'; import {subscribe} from '../../lit/subscription-controller'; import {configModelToken} from '../../../models/config/config-model'; -import {getBaseUrl, prependOrigin} from '../../../utils/url-util'; +import {prependOrigin} from '../../../utils/url-util'; import {CopyLink, GrCopyLinks} from '../gr-copy-links/gr-copy-links'; import { ChangeChildView, @@ -1240,7 +1240,7 @@ private renderCopyLinksDropdown() { const url = this.computeChangeUrl(); if (!url) return; - const changeURL = prependOrigin(getBaseUrl() + url); + const changeURL = prependOrigin(url); const links: CopyLink[] = [ { label: 'Change Number',
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts index daf0257..560006b 100644 --- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts +++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
@@ -21,6 +21,7 @@ mockPromise, pressKey, queryAndAssert, + stubBaseUrl, stubFlags, stubRestApi, waitUntil, @@ -1649,4 +1650,36 @@ copyLinksDialog.copyLinks.some(copyLink => copyLink.value === sha) ); }); + + test('copy links without a base URL', async () => { + element.change = createChangeViewChange(); + await element.updateComplete; + + const copyLinksDialog = queryAndAssert<GrCopyLinks>( + element, + 'gr-copy-links' + ); + assert.deepEqual(copyLinksDialog.copyLinks[1], { + label: 'Change URL', + shortcut: 'u', + value: 'http://localhost:9876/c/test-project/+/42', + }); + }); + + test('copy links with a base URL having a path', async () => { + stubBaseUrl('/review'); + element.change = createChangeViewChange(); + await element.updateComplete; + + const copyLinksDialog = queryAndAssert<GrCopyLinks>( + element, + 'gr-copy-links' + ); + + assert.deepEqual(copyLinksDialog.copyLinks[1], { + label: 'Change URL', + shortcut: 'u', + value: 'http://localhost:9876/review/c/test-project/+/42', + }); + }); });