-
Notifications
You must be signed in to change notification settings - Fork 241
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
Support trailing slashes in paths #1584
Support trailing slashes in paths #1584
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contributions, a couple of recommendations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for making the update, I think we're getting closer to a solution here. Left a couple of comments
{ "/cars/{car-id}/build/", ["cars", "{car-id}"], "build/", @"\cars\{car-id}\build/" }, | ||
{ "/cars/", [], "cars/", @"\cars/" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ "/cars/{car-id}/build/", ["cars", "{car-id}"], "build/", @"\cars\{car-id}\build/" }, | |
{ "/cars/", [], "cars/", @"\cars/" }, | |
{ "/cars/{car-id}/build/", ["cars", "{car-id}"], @"build\", @"\cars\{car-id}\build\" }, | |
{ "/cars/", [], "cars/", @"\cars\" }, |
wouldn't this make more sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's for you to say.
My interpretation was that \
was used as as a hierarchy separator, and given the last /
is not a separator per-se, we might want to keep it as-is to indicate that the last segment is <whatever>/
.
If you want the changes in, though, that's fine, I'll push them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as long as it doesn't derail the logic/node structure, it'd make sense to be consistent.
@darrelmiller I can't remember why backslashes were originally used here instead of forward slashes, would you mind providing some context please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find out why we used backslash as a separator. It doesn't make sense to me. I tried looking at all the relevant PRs. Maybe @irvinesunday remembers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't used backslash anywhere as a separator within this codebase 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, thanks for your patience with us @mderriey it seems we suffer from collective amnesia.
In the interest of unblocking this PR, and reducing potential side effects, let's perform the least changes possible, and align everything on backslashes.
// Remove the last element, which is empty, and append the trailing slash to the new last element | ||
// This is to support URLs with trailing slashes | ||
Array.Resize(ref segments, segments.Length - 1); | ||
segments[segments.Length - 1] += "/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
segments[segments.Length - 1] += "/"; | |
segments[segments.Length - 1] += @"\"; |
fixes #1580
This is a very naïve attempt at supporting trailing slashes in paths.
Please let me know if there are other cases that would need to be covered by the tests, or if this implementation would break in specific scenarios.