Escape Characters in links

0 votes
asked Aug 11, 2020 in Question / help by Kidau (120 points)


In hyperlinks, round brackets { } are used for optional tooltips. 

I want to used links to point to API documentation and URLs are like that (for instance): /get-/customers/{customerId}

Is it possible to escape round brackets in order to have conditionnal parameters and not tooltip ?


commented Aug 12, 2020 by Martin

I'm no expert, I just took interest and did a bit of googling.  But it looks like braces (or curly brackets (don't call them round brackets!), see are bad practice in URIs as they are part of the definition of unsafe characters (see page 3).  They crop up because they are valid characters in URI templates (but not URIs themselves).  I found a few examples of people tripping over this in relation to API documentation:

Notably I leafed through some API documentation for Stackexchange and Facebook, and they don't use curly brackets in the api doc urls.

That said, the correct way to include unsafe characters in a url is to encode them.  So { would be replaced with %7B and } would be replaced with %7D.

I couldn't find a public example url using curly brackets, but here is [a neatly relevant] example that includes an unsafe "^" character, with it also encoded as %5E:

Alice -> Bob : the url [[^what-every-webdev-must-know-about-url-encoding/{Tooltip for message} using ^]]
Alice -> Bob : the url [[{Tooltip for message} using %5E]]

TL;DR; Hopefully encoding { & } as %7B & %7D works for your use case.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.