-
Notifications
You must be signed in to change notification settings - Fork 162
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
URL.deletingLastPathComponent()
should append .. in special cases
#989
Conversation
@swift-ci please test |
XCTAssertEqual(relative.path, "/absolute/relative") | ||
|
||
relative.deleteLastPathComponent() | ||
checkBehavior(relative.relativePath, new: "", old: ".") |
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.
Are there scenarios where this difference between ""
and "."
would actually matter? The only thing I can think of is existing clients using the string literally somewhere else, so this change of behavior breaks their expectation.
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.
Yeah, I don't feel too strongly about returning ""
over "."
, so I think I will make the change to return "."
and maximize compatibility. I could see a client recursively calling .deletingLastPathComponent()
until the relative path matches "."
. I'll edit this PR and #988
We can do this while still accepting URL(string: "", relativeTo: base)
initialization to pass all RFC 3986 examples.
438494e
to
3eef139
Compare
@swift-ci please test |
If a URL's relative path is being resolved against a base URL, we should append ".." as a means of deleting the last path component in the following cases:
Otherwise, we can just remove the last path component as normal.