Skip to content

appendingPathComponent(:isDirectory:) should account for isDirectory #23926

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

Merged
merged 1 commit into from
Oct 4, 2020

Conversation

Coeur
Copy link
Contributor

@Coeur Coeur commented Apr 10, 2019

When appendingPathComponent(:isDirectory:) is falling back from an NSURL.appendingPathComponent() to an NSString.appendingPathComponent(), it's forgetting to take into account the isDirectory parameter.

@@ -827,7 +827,8 @@ public struct URL : ReferenceConvertible, Equatable {
} else {
// Now we need to do something more expensive
if var c = URLComponents(url: self, resolvingAgainstBaseURL: true) {
c.path = (c.path as NSString).appendingPathComponent(pathComponent)
let path = (c.path as NSString).appendingPathComponent(pathComponent)
c.path = isDirectory ? path + "/" : path
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check if a path separator exists here at the end and not double-up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to check the existence of a separator to mimic the behavior of NSURL.appendingPathComponent(:isDirectory:): it will always append a separator.

@millenomi
Copy link
Contributor

cc @compnerd does NSString add forward slashes here? It only converts to Windows paths when getting the FSR, right?

@compnerd
Copy link
Member

@millenomi - yeah, adding the forward slash is fine, the FSR will normalise the path separators. NSURL will add a forward slash.

@millenomi
Copy link
Contributor

@swift-ci please test and merge

@millenomi
Copy link
Contributor

We'll want an equivalent patch for apple/swift-corelibs-foundation, I assume, but I haven't checked if we have equivalent code there.

@Coeur
Copy link
Contributor Author

Coeur commented Apr 11, 2019

@Coeur
Copy link
Contributor Author

Coeur commented Apr 12, 2019

@millenomi can you run the merge again? CI didn't pass for some reason.

@compnerd
Copy link
Member

@swift-ci please test and merge

@CodaFi
Copy link
Contributor

CodaFi commented Feb 10, 2020

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 4c30f8b

@Coeur

This comment has been minimized.

@shahmishal
Copy link
Member

@swift-ci clean test macOS

@Coeur
Copy link
Contributor Author

Coeur commented Feb 12, 2020

@compnerd @CodaFi
I'm not seeing what failed in "Test and Merge" (details return a 404).

@shahmishal
Copy link
Member

@Coeur Test and merge check is used to trigger other required tests. You dont need to have "Test and Merge" passing, anyone with commit access should be able to merge this PR now because it passed required testing.

@CodaFi
Copy link
Contributor

CodaFi commented Feb 13, 2020

Since it’s been a few days,

@swift-ci please smoke test

@Coeur
Copy link
Contributor Author

Coeur commented Mar 23, 2020

@millenomi @CodaFi can we get it merged? Thank you.

@CodaFi
Copy link
Contributor

CodaFi commented Mar 23, 2020

It's up to Foundation.

@millenomi @parkera

@CodaFi
Copy link
Contributor

CodaFi commented Apr 14, 2020

rdar://61796888

@shahmishal
Copy link
Member

Please update the base branch to main by Oct 5th otherwise the pull request will be closed automatically.

  • How to change the base branch: (Link)
  • More detail about the branch update: (Link)

@xwu xwu changed the base branch from master to main October 1, 2020 12:58
@xwu
Copy link
Collaborator

xwu commented Oct 1, 2020

@millenomi Looks like you’d approved but merge bots failed. Still OK to merge?

@millenomi
Copy link
Contributor

Let's try again.

@millenomi
Copy link
Contributor

@swift-ci please test and merge

@millenomi
Copy link
Contributor

If there is a test failure, we can examine it and go from there.

@xwu
Copy link
Collaborator

xwu commented Oct 1, 2020

@swift-ci please test

@xwu xwu merged commit c02dc72 into swiftlang:main Oct 4, 2020
@Coeur Coeur deleted the patch-1 branch October 10, 2020 09:25
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.

7 participants