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

Support trailing slashes in paths #1584

Merged
merged 4 commits into from
Sep 25, 2024
Merged

Support trailing slashes in paths #1584

merged 4 commits into from
Sep 25, 2024

Conversation

mderriey
Copy link
Contributor

@mderriey mderriey commented Mar 6, 2024

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.

Copy link
Member

@baywet baywet left a 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.

Copy link
Member

@baywet baywet left a 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

Comment on lines +473 to +474
{ "/cars/{car-id}/build/", ["cars", "{car-id}"], "build/", @"\cars\{car-id}\build/" },
{ "/cars/", [], "cars/", @"\cars/" },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ "/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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Member

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?

Copy link
Contributor

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 🤔

Copy link
Member

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] += "/";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
segments[segments.Length - 1] += "/";
segments[segments.Length - 1] += @"\";

@MaggieKimani1 MaggieKimani1 merged commit 7fa2f2c into microsoft:vnext Sep 25, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

Support trailing slashes in OpenAPI paths
5 participants