Skip to content

Conversation

@compnerd
Copy link
Contributor

URL.path is not a usable rendering of the path. URL.path represents the URI path. If the path is meant to be consumable as a file path, the file system representation (aka FSR) must be retrieved.

Unfortunately, the FSR access is a bit more complicated as the API for that returns a +0 borrowed object with the lifetime bound to URL. Because this relies on the toll-free bridged storage of URL, Swift does not have this. Instead, we are provided a
withUnsafeFileSystemRepresentation which provides a heap allocated buffer that is scoped, which we can copy into a String. To abstract away this wart, we introduce an extension on URL to access the FSR through the new filepath property.

This improves the file path handling and makes additional tests now pass.

@compnerd
Copy link
Contributor Author

CC: @SimplyDanny @roman-bcny

@SwiftLintBot
Copy link

SwiftLintBot commented Nov 21, 2025

1 Warning
⚠️ If this is a user-facing change, please include a CHANGELOG entry to credit yourself!
You can find it at CHANGELOG.md.
18 Messages
📖 Building this branch resulted in a binary size of 26776.05 KiB vs 26775.45 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 0.8 s vs 0.76 s on main (5% slower).
📖 Linting Alamofire with this PR took 1.03 s vs 1.06 s on main (2% faster).
📖 Linting Brave with this PR took 6.75 s vs 6.79 s on main (0% faster).
📖 Linting DuckDuckGo with this PR took 21.71 s vs 21.71 s on main (0% slower).
📖 Linting Firefox with this PR took 10.82 s vs 10.83 s on main (0% faster).
📖 Linting Kickstarter with this PR took 7.48 s vs 7.48 s on main (0% slower).
📖 Linting Moya with this PR took 0.47 s vs 0.43 s on main (9% slower).
📖 Linting NetNewsWire with this PR took 2.26 s vs 2.21 s on main (2% slower).
📖 Linting Nimble with this PR took 0.68 s vs 0.59 s on main (15% slower).
📖 Linting PocketCasts with this PR took 6.9 s vs 6.89 s on main (0% slower).
📖 Linting Quick with this PR took 0.4 s vs 0.37 s on main (8% slower).
📖 Linting Realm with this PR took 3.21 s vs 3.21 s on main (0% slower).
📖 Linting Sourcery with this PR took 1.8 s vs 1.77 s on main (1% slower).
📖 Linting Swift with this PR took 4.17 s vs 4.15 s on main (0% slower).
📖 Linting VLC with this PR took 1.1 s vs 1.07 s on main (2% slower).
📖 Linting Wire with this PR took 17.39 s vs 17.28 s on main (0% slower).
📖 Linting WordPress with this PR took 11.34 s vs 11.3 s on main (0% slower).

Here's an example of your CHANGELOG entry:

* correct incorrect handling of file paths.  
  [compnerd](https://github.com/compnerd)
  [#issue_number](https://github.com/realm/SwiftLint/issues/issue_number)

note: There are two invisible spaces after the entry's text.

Generated by 🚫 Danger

@compnerd compnerd force-pushed the path branch 2 times, most recently from 38c399c to 8e2e62c Compare November 23, 2025 20:06
`URL.path` is not a usable rendering of the path. `URL.path` represents
the URI path. If the path is meant to be consumable as a file path, the
file system representation (aka FSR) must be retrieved.

This improves the file path handling and makes additional tests now
pass.
@compnerd
Copy link
Contributor Author

@SimplyDanny I think that I will need a little bit of help here. The current failure seems to be unrelated to my change and might be a general configuration issue. It does seem that this change is passing the CI and does improve the test coverage on Windows. I'm not sure that brace expansion is required - the musl path does not support that either. Please let me know if there is anything else that this needs.

@SimplyDanny
Copy link
Collaborator

I think this was just a hiccup in the pipeline. Works now after retriggering it.

I'll have a look at the changes later.

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.

3 participants