Skip to content

Commit

Permalink
MWPW-152952 Allow message for Marketo form success
Browse files Browse the repository at this point in the history
  • Loading branch information
meganthecoder committed Jul 9, 2024
1 parent 8e6ca69 commit c899d0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/blocks/marketo/marketo.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const formValidate = (form) => {
};

export const decorateURL = (destination, baseURL = window.location) => {
if (!(destination.startsWith('http') || destination.startsWith('/'))) return null;

try {
let destinationUrl = new URL(destination, baseURL.origin);
const { hostname, pathname, search, hash } = destinationUrl;
Expand Down
6 changes: 6 additions & 0 deletions test/blocks/marketo/marketo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@ describe('marketo decorateURL', () => {
const result = decorateURL('/marketo-block/thank-you', baseURL);
expect(result).to.equal('https://business.adobe.com/uk/marketo-block/thank-you.html');
});

it('Does not decorate non-url text', () => {
const baseURL = new URL('https://business.adobe.com/marketo-block.html');
const result = decorateURL('Thank you for submitting the form', baseURL);
expect(result).to.be.null;
});
});

0 comments on commit c899d0a

Please sign in to comment.