Files
ghostty/macos/Sources/Helpers/Extensions/URL+Extension.swift
Mitchell Hashimoto 2de1596115 macos: normalize action working directory paths
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.
2026-08-27 14:35:01 -07:00

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
}
}