Eatdoku
Eatdoku

Reputation: 6951

Is % percentage a valid url character

I am trying to put a url, something like the following urn:test.project:123, as part of the url.

Does it make sense to encode urn:test.project:123 into urn%3atest.project%3a123 and decode it back to urn:test.project:123 at the receiver end?

http://{domain}/abc/urn%3atest.project%3a123/Manifest

Upvotes: 1

Views: 3496

Answers (2)

Kirk Woll
Kirk Woll

Reputation: 77556

Yes, it's a valid character. It's the escape character for URLs in a similar way to how the ampersand & is the escape character for xml/html, and the backslash \ is the escape character for string literals in c-like languages. It's the (very important) character that allows you to specify (through an escape sequence) all the other characters that wouldn't be valid in a URL.

(And yes, it makes sense to encode such a string so it's a legal URL, and as @PaulPRO mentions, most frameworks will automatically decode it for you on the server-side.)

Upvotes: 2

Paul
Paul

Reputation: 141827

Yes, the %3a means that 3a is the HEX encoded value for ':' If you put it in the url as %3a your server will most likely automatically decode it.

Upvotes: 1

Related Questions