mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-09-14 18:01:58 +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.
26 lines
793 B
Swift
26 lines
793 B
Swift
import Foundation
|
|
import Testing
|
|
@testable import Ghostty
|
|
|
|
struct URLTests {
|
|
@Test func pathWithoutTrailingSlash() {
|
|
let url = URL(string: "file:///tmp/example/")!
|
|
#expect(url.pathWithoutTrailingSlash == "/tmp/example")
|
|
}
|
|
|
|
@Test func pathWithoutMultipleTrailingSlashes() {
|
|
let url = URL(string: "file:///tmp/example///")!
|
|
#expect(url.pathWithoutTrailingSlash == "/tmp/example")
|
|
}
|
|
|
|
@Test func pathWithoutTrailingSlashDecodesPath() {
|
|
let url = URL(string: "file:///tmp/example%20directory/")!
|
|
#expect(url.pathWithoutTrailingSlash == "/tmp/example directory")
|
|
}
|
|
|
|
@Test func pathWithoutTrailingSlashPreservesRoot() {
|
|
let url = URL(string: "file:///")!
|
|
#expect(url.pathWithoutTrailingSlash == "/")
|
|
}
|
|
}
|