Purpose of tilde delimited values in URL fragment instead of GET params

231 Views Asked by At

I came across an unusual URL structure on a site. It looked like this:

https://www.agilealliance.org/glossary/xp/#q=~(infinite~false~filters~(postType~(~'post~'aa_book~'aa_event_session~'aa_experience_report)~tags~(~'xp))~searchTerm~'~sort~false~sortDirection~'asc~page~1)

It seems the category, pagination and sort options of a widget on the page injects and reads through these values. Does this format for storing data in the URL have a name, or is this an esoteric format someone made?

What's the purpose of doing this over using regular GET params, or at least using a more conventional format after the fragment?

2

There are 2 best solutions below

1
CodeCaster On

If you inspect the URL carefully, you'll see that the parameters you describe are placed after the fragment (#), meaning they're not sent to the server but used by the client instead.

In this case, the client (JavaScript) builds them into something like an ElasticSearch query that's then POSTed to the server, in order to update listing you see on your screen.

2
Jamie On

Probably the reason those tildes were chosen is because they are one of the very few non-alphanumeric characters that can be used in a URL without needing to be URL encoded (i.e. encoded with a % sign). The others are the hyphen ("-"), underscore ("_"), and period ("."). See What are the safe characters for making URLs?

Since the tilde is the most uncommon of these characters, it is a convenient delimiter for splitting up the queries into their component parts.