Remix.run Logo
drcongo 2 days ago

I quite like the semi-colons. I wonder how we ended up with the slightly unwieldy ?foo=bar&some=thing

pavlov 2 days ago | parent | next [-]

Think “how do I implement a search engine whose interface is visible in the browser address bar?” This was a reasonable question on the early web. And that’s why they are called query params.

The question mark indicates you’re making a query. And the ampersand is a boolean operator. You could imagine query params implementing | in addition to &.

drcongo 2 days ago | parent [-]

I think to non-techies the semi-colons are still more intuitive - I often see non-technical people mess up the ? and &, either by using just one of them or by getting them the wrong way around.

doublerabbit 2 days ago | parent [-]

I chuckled once when driving having a radio adverts announce "enter in your web browser something.com slash question-mark prize ampersand win to win!"

TRiG_Ireland 2 days ago | parent | prev | next [-]

I'm certain I've seen websites which used semi-colons rather than question marks and ampersands for query parameters. The Jehovah's Witnesses website used to, many years ago. I believe that one of the reasons behind this design was that it meant that there were no special characters which needed to be escaped in HTML. This design works fine for links, but not for forms, which will generate normal URLs containing question marks and ampersands. I suppose you can use POST-Redirect-GET forms, and generate your own URLs using semi-colons.

_micheee 2 days ago | parent | prev | next [-]

Seems Like the recommendation changed from supporting ; and & to only using &.

Thinking about it, it is a little surprising as, if I remember correctly, in HTML source you should encode & as & right?

Sardtok 2 days ago | parent [-]

& as an escape character only applies to text nodes. Of course, if you want to display the URL on a page, you have to escape it, but not in the href.

_micheee 2 days ago | parent | next [-]

I just found out you may - even in current HTML use entity references in attribute values, it’s just you don’t have to anymore, when the ampersand is not ambiguous.

The spec states it as: “Attribute values are a mixture of text and character references, except with the additional restriction that the text cannot contain an ambiguous ampersand.”

Whereas in the the days before HTML5 this has been mandatory.

> HTML 4.01 Specification – Appendix B.2.2 “Ampersands in URI attribute values”

https://www.w3.org/TR/html401/appendix/notes.html#h-B.2.2

> Unfortunately, the use of the “&” character to separate form fields interacts with its use in SGML attribute values to delimit character entity references.

someonebaggy 2 days ago | parent [-]

That's the same as main body text isn't it? And you have to be able to use them so you can escape " just like you have to escape < in main text.

HTML5 standardized how to interpret formerly invalid documents because it was more important to be consistent than to be correct.

ShinyLeftPad 2 days ago | parent | prev | next [-]

You're supposed to escape & anywhere in HTML, not just in text nodes. If you don't (and many don't) it'll probably work, but browser first tries to interpret it as a start of an entity anyway. Even if it is inside a href etc.

bawolff 2 days ago | parent | prev [-]

That is incorrect. Entities apply to attributes.

In HTML escaping & is kind of optional and the browser just tries to figure out what you mean, but if you are doing things properly you should use &amp; in href attributes.

ErroneousBosh 2 days ago | parent | prev [-]

Is there any reason we couldn't just use that anyway?

TRiG_Ireland 2 days ago | parent | next [-]

If you're relying on HTML forms being filled in to generate queries, the browser will always generate standard query parameters with a question mark and ampersands. But if you're making your own links, you can generate them however you like. Semi-colons should work fine, though you may need to write your one URL parsing functions.

Neikius 2 days ago | parent [-]

Iirc in java I managed to parse those just fine. Ages ago though.

I also recall actually seeing some web pages somewhere using semicolon, possibly IBM stuff.

echoangle 2 days ago | parent | prev | next [-]

I think some browsers display the query params muted compared to the part before (or maybe I’m confusing it with the behavior that the domain is highlighted to prevent phishing?). But technically, you can just parse the request url however you want. I also think it shouldn’t matter with regards to any caching layers inbetween.

kazinator 2 days ago | parent | prev | next [-]

Just one minor one why you might not want to. HTTP{S}? handling objects understand the URL parameter syntax and do parsing for you, so when you write a request handler, you are dealing with structured dictionaries of request headers and URL parameters.

iainmerrick 2 days ago | parent | prev [-]

You can use it if you want, but the browser doesn’t help you at all. It can’t automatically turn a form into a matrix URI, and it can’t do anything useful with relative matrix URIs.

flyingshelf 2 days ago | parent [-]

You're saying that as if developers have cared about the platform in the past twenty years. Use JS, everything is possible, even turning a div into a link, apparently.