-
Notifications
You must be signed in to change notification settings - Fork 125
preserve trailing slash in uri path #107
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
Conversation
pathEndIndex = url.index(before: fragmentIndex) | ||
} | ||
|
||
return url[pathEndIndex] == "/" |
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.
Writing this against the absolute string seems to be making life quite hard: why not write it against self.path
?
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.
self.path
removes trailing slash
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.
Can we step back for a minute: why is the current behaviour of URL problematic today?
If a server has a redirect like |
It's a shame that server is broken. |
pathEndIndex = url.index(before: queryIndex) | ||
} else if let fragmentIndex = url.suffix(from: url.firstIndex(of: "@") ?? url.startIndex).lastIndex(of: "#") { | ||
pathEndIndex = url.index(before: fragmentIndex) | ||
} |
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.
Do we need the else
branch? The minimum versions above were all released in 2015, making them 4 years old this year. Can we get away without it?
If the answer is really no, then can we also add a comment to this code branch to say that the code is not 100% correct, but is considered "good enough"?
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.
What do you mean by getting away without it? Adding supported platforms in Package.swift
or a precondition? I would prefer not to have an alternative clause here as well...
@tomerd @tanner0101 @ianpartridge do you think we should limit the client to modern(er) platforms?
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.
given our main use case is linux, restricting older non-linux platforms in Package.swift seems fine to me
@Lukasa fixed path check by using |
Package.swift
Outdated
@@ -17,6 +17,7 @@ import PackageDescription | |||
|
|||
let package = Package( | |||
name: "async-http-client", | |||
platforms: [.macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2)], |
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.
would this potentially confuse folks to think linux is not supported? maybe worth adding a comment?
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.
added a comment!
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 think we need to take this out. If we don't then every dependency needs to mirror this stanza.
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 LGTM
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.
Sorry, the patch itself looks good but the platform restriction is probably too annoying.
Package.swift
Outdated
@@ -17,6 +17,7 @@ import PackageDescription | |||
|
|||
let package = Package( | |||
name: "async-http-client", | |||
platforms: [.macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2)], |
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 think we need to take this out. If we don't then every dependency needs to mirror this stanza.
Agreed, reverted |
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.
lgtm
fixes #101 by preserving trailing slash in path return by the
URL's
path
property