Hi guys, having troubles with call.parameter with ...
# ktor
a
Hi guys, having troubles with call.parameter with "+" as a character. I have ContentNegotiation and DataConversion setted. Someone knows what can it be? Thanks.
m
What is the trouble?
+
in a URL query parameter means a space character. If you wand to send a real
+
then you have to escape it.
a
Yes you are right, I get an space. I need to get a "+"
m
Then the problem is probably on the client side and the request URL is invalid.
a
Yes, you are right, many thanks
In this case I have an email parameter and the email has a "+"
How could you handle it?
m
If you put some data in a URL you have to escape the data first. How do you construct your URL? Do you use Ktor’s
Url
?
a
The data is construct by the client
m
How?
a
path/?email={email}
m
You, you have to escape
email
before putting it into that URL.
With Ktor you could use
email.encodeURLParameter()
No idea what client you use.
Or language.
In JS/TS it would be
encodeURIComponent(email)
a
JS
Perfect, gonna try it
encodeURLParameter(true)
first param is spaceToPlus
works
👍 1
now the problems is that the
@
is also
%40
m
Yeah that’s okay
Correct in a URL
c
In general, be very aware about emails. Emails are a very weird format: emails can have spaces, quotes, etc.
☝️ 1