menu

Mockoon

Mockoon's official community. Get help, discuss new features.

Channels
Chat
view-forward
# All channels
view-forward
# General
view-forward
# Announcements
view-forward
# Bugs
view-forward
# Features
view-forward
# Help
view-forward
Team

URL Encoding Options Needed

December 5, 2019 at 6:28pm

URL Encoding Options Needed

December 5, 2019 at 6:28pm
I have an API I'm simulating and the device doesn't accept proper URL encoding. If I use a '+' character in the URL route as the device uses in reality, Mockoon gives me a bad response. I agree the '+' in the URL should be encoded, but the device I'm working with won't accept it that way. I'd like to use Mockoon to simulate the device so I can develop the code to retrieve information, but Mockoon is unable to simulate the device.

December 5, 2019 at 8:43pm
Could you please give me some example of the route declared in Mockoon, and how you call it, so I could test? Do not hesitate to open an issue on the repository so I can track this
  • reply
  • like

December 12, 2019 at 8:45pm
I have a route setup for /vplex/monitor+get-stats . The "+" should be URL encoded as %5B, but the appliance I'm simulating doesn't accept that. When I defined the route in Mockoon as /vplex/monitor%5Bget-stats , it works fine. I use curl on the local machine (windows 10) to verify it's working. I've also done a Wireshark trace and can see the URL in the network traffic and confirmed in has the plus sign in the request. (eliminating any possibility that curl is mangling the request)
  • reply
  • like

December 13, 2019 at 9:46am
There thing is, mockoon routing is based on expressjs which consider the + as an element of a regular expression
  • reply
  • like
So, /a+b will be matched by /aab, /aaab, etc (any number of "a")
  • reply
  • like
I am not sure what the solution is to allow + in route
  • reply
  • like
Maybe detect special character in the request and then url encode, but route would need to be declared encoded I think
  • reply
  • like
Anyway this may need to be tracked in an issue. Feel free to open one on the repository
  • reply
  • like

December 14, 2019 at 1:03am
What if I escape the "+" with + in the route definition? Would that work?
  • reply
  • like
That should be "backslash" plus in the text. It got filtered. :)
  • reply
  • like
It seems to work with the backslash plus-sign. Thanks. You have saved be some work.
  • reply
  • like

December 14, 2019 at 10:14pm
Glad you found a solution! Didn't even know that you could escape the plus sign. I didn't see that in Express documentation
  • reply
  • like