-
Notifications
You must be signed in to change notification settings - Fork 120
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
Enable clients to call URLs that include %2F as an escaped backslash #201
Conversation
Previously `percentEncodedPath` was using `path.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)` which converts %2F to a literal '/'. This prevented users fetching URLs like https://api.travis-ci.org/repo/github/rails%2Frails which use %2F as part of a path segment. Migrating to `URLComponents(url: self, resolvingAgainstBaseURL: false)?.percentEncodedPath` has the desired behaviour for the couple of test cases that exist. Updated the test server to switch on the `percentEncodedPath` so it's easier to understand the desired behaviour.
Can one of the admins verify this patch? |
3 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
@swift-server-bot test this please |
Flaky test: #175. |
@swift-server-bot test this please |
1 similar comment
@swift-server-bot test this 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.
This looks reasonable to me, assuming we can get the dang tests to pass.
@swift-server-bot test this please |
@Lukasa @artemredkin, I just rechecked this locally (disabling the flakey test) and I noticed that I'm hitting a few legitimate failures on let request6 = try Request(url: "https://someserver.com:8888/some/path/")
XCTAssertEqual(request6.url.uri, "/some/path/") // XCTAssertEqual failed: ("/some/path//") is not equal to ("/some/path/") |
} | ||
|
||
var uri: String { | ||
var uri = self.percentEncodedPath | ||
if self.pathHasTrailingSlash, uri != "/" { |
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.
So it seems this case is handled correctly through the URLComponenets.percentEncodedPath
approach. This behaviour looks well tested in testRequestURITrailingSlash
which should now be passing (at least on iOS and macOS).
I pushed another commit that removes some redundant code. Would one of you mind re-triggering CI? Also happy to squash the commits if that is preferred here. |
@swift-server-bot test this please |
Hi 👋, thanks for all the great work on this project.
I have a package that calls the Travis API, which uses %2F as part of the URL path segment. This PR adds a test case & migrates to
URLComponents(url: self, resolvingAgainstBaseURL: false)?.percentEncodedPath
which covers that use case.I also updated the test server to switch on the
percentEncodedPath
so it's easierto understand the desired behaviour. I've tested this locally on 10.15.4 but not on Ubuntu.