OPTIMADE icon indicating copy to clipboard operation
OPTIMADE copied to clipboard

Trailing slashes in URLs

Open merkys opened this issue 3 years ago • 3 comments

The COD implementation currently does not handle endpoint URLs with trailing slashes. While this issue is relatively easy to fix on the COD side, I am interested in OPTIMADE's stance on whether trailing slashes MUST/SHOULD/MUST NOT be supported. Both the current specification and its parent JSON::API seem silent on the issue, although URLs without trailing slashes are prevalent in provided examples. There is, however, a single example in OPTIMADE specification showcasing a trailing slash:

http://example.com/optimade/v1/structures/?filter=a=1 AND b=2

I personally would explicitly forbid URLs with trailing slashes in order to maintain greater visual difference between entry listing endpoints (/structures) and individual entries (/structures/1).

merkys avatar Oct 14 '20 07:10 merkys

I can see your argument, but could it not be that the requirement of not allowing trailing slashes may be difficult in some web frameworks?

rartino avatar Oct 14 '20 08:10 rartino

I can see your argument, but could it not be that the requirement of not allowing trailing slashes may be difficult in some web frameworks?

Might be so. Then it's probably better to allow the implementations to serve URLs with trailing slashes, but discourage the users from relying on this feature.

merkys avatar Oct 14 '20 08:10 merkys

In the web meeting of 2020-10-28 @sauliusg has brought our attention to RFC 1738, which says:

An HTTP URL takes the form:

  http://<host>:<port>/<path>?<searchpart>

[omit]

Within the <path> and <searchpart> components, "/", ";", "?" are reserved. The "/" character may be used within HTTP to designate a hierarchical structure.

Thus I read that even the hierarchical structure is not mandated. So it's up to us to decide what we do. JSON::API, by the way, does not seem to mandate URL structure at all (although examples display a nice pattern).

merkys avatar Oct 29 '20 11:10 merkys