Decode Base64 on Frontend

I am trying to pass in a query parameter a URL that would contain another url.

Example: www.domain.com?fwd=Param1
and Param1 could have a random value such as: /page?p=1 or it could be /folder/page?p=1

In order to workaround this, I want to use Base64 encoding (ar any other URL encoding). Is there a way to do it on the front end?
Thanks

Perhaps I should make a tutorial on how to create your own custom formatters for App Connect.

Here a very simple one for base64 encoding:

dmx.Formatters('string', {
    encodeBase64: btoa,
    decodeBase64: atob
});

Usage:
{{ 'Hello world'.encodeBase64() }} becomes SGVsbG8gd29ybGQ=
{{ 'SGVsbG8gd29ybGQ='.decodeBase64() }} becomes Hello world

2 Likes

Great, thanks @patrick, where shall I insert the below? in the header?

dmx.Formatters('string', {
    encodeBase64: btoa,
    decodeBase64: atob
});

As long as the script block is below the dmxAppConnect.js include it should work.

1 Like