diff --git a/libs/blocks/marketo/marketo.js b/libs/blocks/marketo/marketo.js index e496345174..a6cfb7a2e7 100644 --- a/libs/blocks/marketo/marketo.js +++ b/libs/blocks/marketo/marketo.js @@ -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; diff --git a/test/blocks/marketo/marketo.test.js b/test/blocks/marketo/marketo.test.js index f3ab41549c..b986b6b2cb 100644 --- a/test/blocks/marketo/marketo.test.js +++ b/test/blocks/marketo/marketo.test.js @@ -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; + }); });