Fixed error closing donation success modal

no issue

- when redirecting from Stripe back to Ghost after making a donation the URL contained a double slash (`//#/portal/...`) which triggered browser security errors when Portal modified the browser history stack when navigating
- the above could prevent the donation success modal from closing
This commit is contained in:
Kevin Ansfield 2024-08-28 11:56:41 +01:00
parent 1871269e8f
commit 32edc12cc2
3 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@tryghost/portal", "name": "@tryghost/portal",
"version": "2.42.0", "version": "2.42.1",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -14,7 +14,7 @@ const SupportPage = () => {
async function checkoutDonation() { async function checkoutDonation() {
const siteUrl = window.location.origin; const siteUrl = window.location.origin;
const currentUrl = siteUrl + window.location.pathname; const currentUrl = siteUrl + window.location.pathname;
const successUrl = member ? `${currentUrl}?action=support&success=true` : `${currentUrl}/#/portal/support/success`; const successUrl = member ? `${currentUrl}?action=support&success=true` : `${currentUrl}#/portal/support/success`;
const cancelUrl = currentUrl; const cancelUrl = currentUrl;
const api = setupGhostApi({siteUrl}); const api = setupGhostApi({siteUrl});

View File

@ -18,6 +18,7 @@ test.describe('Portal', () => {
await sharedPage.pause(); await sharedPage.pause();
// Check success modal // Check success modal
await sharedPage.waitForSelector('[data-testid="portal-popup-frame"]', {state: 'visible'}); await sharedPage.waitForSelector('[data-testid="portal-popup-frame"]', {state: 'visible'});
expect(sharedPage.url()).toMatch(/[^\/]\/#\/portal\/support\/success/); // Ensure correct URL and no double-slash
const portalFrame = sharedPage.frameLocator('[data-testid="portal-popup-frame"]'); const portalFrame = sharedPage.frameLocator('[data-testid="portal-popup-frame"]');
await expect(portalFrame.getByText('Thank you for your support')).toBeVisible(); await expect(portalFrame.getByText('Thank you for your support')).toBeVisible();
// Modal has working subscribe action // Modal has working subscribe action