Skip to content

Conversation

@jrflat
Copy link
Contributor

@jrflat jrflat commented Jul 8, 2025

Minor fix for String.pathExtension found when comparing the old NSString behavior. String.pathExtension returns "" for path extensions appended to "." and ".." file names. This behavior is in part to prevent .deletingPathExtension() from returning a path referencing the current or parent directory.

However, String.pathExtension currently returns "" for all file names that start with "..", so some valid file paths like "..name.txt" aren't receiving the correct behavior.

This PR makes it so we only disallow extensions that would leave "." and ".." file names when removed. I also renamed a variable to make it more clear we're working with the UTF8View.

@jrflat
Copy link
Contributor Author

jrflat commented Jul 8, 2025

@swift-ci please test

@jrflat jrflat requested review from jmschonfeld and parkera July 8, 2025 22:32
@jrflat jrflat merged commit a78bd00 into swiftlang:main Jul 8, 2025
16 checks passed
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