I am handling some hashtag processing in a rails application.
Say us that I have programmed an endpoint which receives through params
hash a string containing some hashtags. Some like that
This string contains this #hashtag and this #one
.
I am using postman for testing my endpoints.
Now, when in postman I perform some like this:
{{url}}/add?content=content=This string contains this #hashtag and this #one
I receive in the params
the string "content"=>"This string contains this "
. That is, from the first occurrence of symbol #
the remaining string is cut.
Very aware that my question is some naive, I dare to ask why that? What have I done wrong? and how could I manage for passing strings containing the #
symbol?
You need to make sure you encode whatever you are sending over in param.
URI.encode("This string contains this #hashtag and this #one")
#=> This%20string%20contains%20this%20%23hashtag%20and%20this%20%23one
Update your postman request to replace the #
with %23
{{url}}/add?content=This string contains this %23hashtag and this %23one
In the future when doing something like this you can select a part of the params(or the whole thing) and right click and select EncodeURIComponent
, as explained here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.