Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is /foo != /foo/ ? #240

Closed
bblfish opened this issue Feb 23, 2021 · 5 comments
Closed

Is /foo != /foo/ ? #240

bblfish opened this issue Feb 23, 2021 · 5 comments

Comments

@bblfish
Copy link
Member

bblfish commented Feb 23, 2021

In a discussion on gitter @csarven's wrote:

Container and contained resources can be distinguished. If /foo exists, /foo/ can't exist, and vice versa

But the text of URI Slash Semantics seems to say the opposite

If two URIs differ only in the trailing slash, and the server has associated a resource with one of them, then the other URI MUST NOT correspond to another resource.

That seems to say the two resources MUST be the same.

But @RubenVerborgh's Node Solid Resource Mapping JS which maps URLs to files seems to me to quite clearly distinguish between URLs ending in a / and one's that don't. URLs ending with a / are mapped to directories. (I got this from a discussion on file mappings)

const isFolder = filePath.endsWith('/')

And on line 115 the content type extension is added to the path that is a request for /foo with text/html should return /foo.html

if (!isFolder) {
        path = this._addContentTypeExtension(path, contentType)
 }

whereas if the path ends with a / then the path is appended with the index file name, i.e., /foo/ turns into /foo/index.html for example.

 path += this._indexFilename

For what it is worth, intuitively the difference makes sense. I think one could even add a Stylistic guidance such as: If both /foo and /foo/ exist, then /foo should give an external description of /foo/ which will give an internal description of the contents, if an RDF request is made.

That will then leave the question as to whether an RDF file can be an index for a container, as that would then never show the contents, or if the contents should be appended to the container.

Also the last sentence does not make sense

Behaviour pertaining to authorization MUST proceed this optional redirect

It may do if proceed is changed to precede

@TallTed
Copy link
Contributor

TallTed commented Feb 23, 2021

PR #241 will fix the proceed -> precede issue you flagged at the end. As to the preceding...

In a discussion on gitter @csarven wrote:

Container and contained resources can be distinguished. If /foo exists, /foo/ can't exist, and vice versa

But the text of URI Slash Semantics seems to say the opposite

You seem to have an unusual definition of "opposite."

If two URIs differ only in the trailing slash, and the server has associated a resource with one of them, then the other URI MUST NOT correspond to another resource.

I don't see anything in this that contradicts the earlier.

If /foo corresponds to a resource (i.e., exists), then /foo/ MUST NOT correspond to another resource (which is true if /foo/ doesn't exist).

That seems to say the two resources MUST be the same.

It does NOT say that both URIs MUST correspond to any resource (so it does allow for the 404s @csarven might be suggesting), but it might be read to say that if they both do correspond to any resource, then both must correspond to the same resource.

I don't see either as forbidding 3xx redirection from /foo to /foo/ or vice versa.

@bblfish
Copy link
Member Author

bblfish commented Feb 23, 2021

When I read Node Resource-mapper I get the feeling that /cat and /cat/ can be completely different things: the first a /cat.jpg and the second an /cat/index.html file for example. Whereas from your interpretation @TallTed the situation seems to be that the first should redirect to the second, which makes them a lot less different. I did not read anything about one existing but the other not. If that is important it should be played out more clearly.

I am providing feedback, as I am attempting to implement this now.

@bblfish
Copy link
Member Author

bblfish commented Feb 23, 2021

@RubenVerborgh wrote:

If /foo exists, /foo/ can't exist as a separate resource

but that seems to clash with my reading of your Node Solid Resource Mapping I gave above.

I now understand @csarven's answer on gitter though. (I was coming at this from studying that code, so I was convinced they both could exist)

@bblfish
Copy link
Member Author

bblfish commented Feb 23, 2021

The first part of the sentence does speak about them being distinguished, which was what strengthened my view that they were different.

Container and contained resources can be distinguished.

Anyway, having them be the same was closer to how I had already started implement it. Both views seem reasonable. I wonder if there is a deeper reason for not allowing them to be different.

@bblfish
Copy link
Member Author

bblfish commented Feb 24, 2021

Ok, I'll close this issue and perhaps open another one seeking justification for the redirect. I'll first look to see if I can find a justification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants