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

Allow additional path extensions on configured hosts #253

Merged
merged 4 commits into from
Mar 28, 2024
Merged

Conversation

rebello95
Copy link
Collaborator

This adds support for specifying hosts with additional path extensions, such as https://connectrpc.com/a/b/c/. Previously, /a/b/c would be dropped.

Resolves #252.

Also related to #161.

Copy link

@oliverfoggin oliverfoggin left a comment

Choose a reason for hiding this comment

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

Great!

Thanks for making these changes so quickly!

Copy link

@oliverfoggin oliverfoggin left a comment

Choose a reason for hiding this comment

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

Looking at this it appears to add an additional / if one already exists.

In this code...

let url = URL(string: "https://foo.com/x/y/z/")!.appendingPathComponent("/a/b/c")

The resulting URL is...

https://foo.com/x/y/z//a/b/c
image

Thanks

@oliverfoggin
Copy link

It looks like appendingPathComponent("path") is deprecated in favour of appending(path: "path") but this still has the same issue of the doubled //. 😅

image

@rebello95
Copy link
Collaborator Author

Thanks for taking a look @oliverfoggin. I'm not seeing the issue you're describing, and I had added a test case for hosts with trailing / components which passed (I also just updated the tests to explicitly use the /a/b/c examples).

Running locally, this is also what I get:

print(ProtocolClientConfig(host: "https://connectrpc.com/a/b/c/")
    .createURL(forPath: rpcPath))

> https://connectrpc.com/a/b/c/connectrpc.conformance.v1.ConformanceService/Unary

Which is correct, so I'm not sure why the playground is showing something different.

Can you try checking out this branch as your Connect dependency and seeing if it solves your problem?

It looks like appendingPathComponent("path") is deprecated in favour of appending(path: "path")

It doesn't look like it's been fully deprecated, but seems like there is a newly preferred version:

Screenshot 2024-03-28 at 6 09 09 AM

However, the new version is not available in the target SDK for Connect, and I think it'd be safer to have one implementation rather than if #available() and having 2 codepaths since we aren't getting compilation warnings:

Screenshot 2024-03-28 at 6 09 45 AM

@oliverfoggin
Copy link

Hey, I wonder if the URL difference is down to an iOS version or sdk version?

I have checked out the branch and I'm using it now but I had to remove the / from my host to avoid the double // problem. Which is what made me leave that comment.

Something to leave in for now but keep in mind maybe. 😊

👍🏻

Thanks

@rebello95
Copy link
Collaborator Author

Hey, I wonder if the URL difference is down to an iOS version or sdk version?

I have checked out the branch and I'm using it now but I had to remove the / from my host to avoid the double // problem. Which is what made me leave that comment.

That'd be a little scary, though not unheard of 😬 what versions are you using today? I'm using Xcode 15.2 on macOS Sonoma 14.2.1.

@rebello95
Copy link
Collaborator Author

CI failures are unrelated, working with @jhump to resolve

@rebello95 rebello95 merged commit 06b8ad4 into main Mar 28, 2024
13 checks passed
@rebello95 rebello95 deleted the fix-path-ext branch March 28, 2024 22:26
@oliverfoggin
Copy link

I'm on Xcode 15.3 and Sonoma 14.4

Thanks for the update with this. Will check it out and continue on with the project. 😄

@oliverfoggin
Copy link

@rebello95

Would it be possible to put a release out for this change? I'm pointing at main at the moment to get the change.

Thanks

@rebello95
Copy link
Collaborator Author

@oliverfoggin yea I think we can create a release once #247 merges

@oliverfoggin
Copy link

Great! Thanks 😃

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.

Can we prepend onto the path to allow for how the server is set up?
3 participants