mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-09-16 19:02:05 +00:00
Discussion #14048 Directory URLs no longer export a trailing slash through PWD, which keeps zsh's %1~ prompt expansion from resolving to an empty string. A shared URL helper removes trailing separators while preserving the filesystem root and percent-decoding behavior. Tests cover normal, repeated, encoded, and root paths.
13 lines
342 B
Swift
13 lines
342 B
Swift
import Foundation
|
|
|
|
extension URL {
|
|
/// The decoded path with trailing separators removed, except for the root path.
|
|
var pathWithoutTrailingSlash: String {
|
|
var result = path(percentEncoded: false)
|
|
while result.count > 1 && result.hasSuffix("/") {
|
|
result.removeLast()
|
|
}
|
|
return result
|
|
}
|
|
}
|