🕷️ BUG: Incorrect URL encoding plus workaround

Several years ago, I discovered a bug in Bubble’s :formatted as URL operator when the “Replace spaces by +” option is enabled (which it is by default). At the time, I didn’t report it because the workaround is trivial.

After seeing this post and this post, I was motivated to double check and discovered that the issue persists in Bubble to this day. So, I finally reported the bug, and I’m providing the details here for the benefit of others until the issue is fully resolved by the Bubble team.

Problem

The “Replace spaces by +” option of the :formatted as URL operator does NOT work properly.

With that setting enabled…

  1. FIRST, all spaces in the string are replaced by + characters.
  2. THEN the string is percent-encoded, which means all the previously added + characters are encoded as %2B.

The net result is that the encoded string will never actually contain any + characters to represent spaces. (see below screenshot from my bug report)

Solution / Workaround

  • The first thing to try is simply disabling the “Replace spaces by +” setting.

    This will encode spaces as %20, which will work in many (probably most) contexts and with most servers (but will result in a larger and less readable encoded string).

  • If you do need (or want) spaces encoded as + characters, then make sure “Replace spaces by +” is disabled (as above), and just append a :find & replace operator to the expression, replacing all occurrences of %20 with + as shown in the screenshot below.

3 Likes

This topic was automatically closed after 14 days. New replies are no longer allowed.