Files
ghostty/macos/Tests/URLTests.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

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 == "/")
}
}