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

fix path segment parsing when suffixed with query #689

Merged
merged 8 commits into from
Jan 5, 2023

Conversation

yisraelU
Copy link
Contributor

In the scenario of a constant query (and perhaps some other cases) parsing of path segments fail.
http://yourhost/my/uri/{foo}?hello=world should parse a label foo, which it currently does not

else if (str.startsWith("{") && str.endsWith("}"))
Some(PathSegment.label(str.substring(1, str.length() - 1)))
else Some(PathSegment.static(str))
Option(str).map { str =>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you got rid of a .isEmpty() here

you may want to reintroduce it as a .filter(_.nonEmpty) on the Option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes , was thinking of Null , will update

PathSegment implementation returns just the path, minus any query parameters
A  staticQueryParams method has been added  HttpEndpoint,
the Http4s client calls that method to retrieve any static query params and pass them on

Tests: metadata.smithy has been modified and PathSpec includes tests for testing the HttpEndpoint functionality
val uri = baseUri
.copy(path = baseUri.path.addSegments(path.map(Uri.Path.Segment(_))))
.withQueryParams(staticQueries)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@Baccata Baccata left a comment

Choose a reason for hiding this comment

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

Good stuff !

@Baccata Baccata merged commit cabb174 into series/0.17 Jan 5, 2023
@Baccata Baccata deleted the fix-path-segments branch January 5, 2023 21:33
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.

None yet

4 participants