Encoding url in Racket
#106
Closed
opened 4 years ago by casouri
·
3 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
I have a bunch of urls that contain Unicode, and I need to encode them. The problem is,
encode-uri
provided innet/uri-codec
encodes reserved characters, sohttps://mysite.com
becomeshttps%3A%2F%2Fmysite.com
. What I really want is to not encode reserved characters and only encode non-ascii characters. I looked around and couldn't find a function that suits my needs. I could roll my own, but surely someone has figured it out, right?This might work for you: parse the URI first and then re-convert it to a string:
If that doesn’t quite cut it, you could parse the string into
url
struct withstring->url
and then do your own encoding on just the path portion.I thought I replied and thanked you but apparently not. I hope this isn't too late ;-) Thanks! Using
url->string
withstring->url
works great.