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

[SR-15363] URL/NSURL.pathComponents splits the percent-decoded path #3195

Open
karwa opened this issue Oct 21, 2021 · 0 comments
Open

[SR-15363] URL/NSURL.pathComponents splits the percent-decoded path #3195

karwa opened this issue Oct 21, 2021 · 0 comments

Comments

@karwa
Copy link
Contributor

karwa commented Oct 21, 2021

Previous ID SR-15363
Radar None
Original Reporter @karwa
Type Bug
Environment

Xcode 13 GM, macOS 11.6

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 7ebd8d45f23feb64d2bd57061f43ab9a

Issue Description:

Consider:

import Foundation

var url = URL(string: "https://github.com/karwa/swift%2Furl")!

// Automatic decoding makes it look like a path separator.
url.path // "/karwa/swift/url"

// URL.pathComponents splits the '.path' property internally.
for component in url.pathComponents { 
  print(component) // "/", "karwa", "swift", "url"
}

// URL.deleteLastPathComponent() uses the raw path instead.
// It looks like it deleted the last 2 components.
url.deleteLastPathComponent() // "https://github.com/karwa/"

This comes from NSURL._pathComponents, which uses the .path property internally. path is automatically-percent decoded; _pathComponents should be splitting the raw, encoded path instead.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant