Decode from URL encoded format

My Server Connect action returns a URL encoded value, how do I decode this in the output, I can see the URL Encode formatter option, but not Decode.

Thanks in advance.

%3Cp%3EI%20love%20Wappler%0ACan%20someone%20help%20%3Cb%3Eplease%3C%2Fb%3E%3C%2Fp%3E

I was about to suggest it as a new feature.

@patrick could this be added to the core?
Use case: when you are encrypting/decrypting strings and sending them via URL parameter you need to encode after encrypting and decode before decrypting.

In the meantime mimuk you can create a custom formatter. I am assuming you are using php.

Create a new file named custom.php or whatever name you want inside /dmxConnectLib/lib/formatters

<?php

namespace lib\core;

function formatter_urldecode($val) {
    return urldecode(strval($val));
}

You can then use .urldecode() wherever you need it.

i.e. {{temp.urldecode()}}

1 Like

The urldecode wasn’t added when we added the urlencode for a reason, the problem was some limitation that we had in Wappler. We couldn’t have formatters for only PHP for example, we had to make them for all server models. The problem was that classic ASP didn’t have an decode, only an encode option.

Will see if we can add it in one of the upcoming updates.

3 Likes

Thanks for the rationale.

Glad I am on php and custom formatters exist :slight_smile:

you guessed it…
Its a classic ASP site I am running. :slightly_frowning_face:

Is there a custom formatter that can be applied to ASP?

Create a file custom.asp with the following content:

<script runat="server" language="jscript" charset="UTF-8">

  exports.urldecode = function(val) {
    return unescape(val);
  }

</script>

Place the file in the dmxConnectLib/lib/formatters folder.

1 Like

Works wonderfully, thanks @JonL and @patrick

1 Like

I see the formatter is not in the UI for server connect, is it still in progress or can i use it with just urldecode().
I know @George normally adds those UI things?

Bump.