Skip to content

Commit a69aab7

Browse files
committed
(137600784) Guard old behavior in URL tests
1 parent 002921d commit a69aab7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Tests/FoundationEssentialsTests/URLTests.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,18 +643,19 @@ final class URLTests : XCTestCase {
643643
var url = URL(filePath: "~")
644644
// "~" must either be expanded to an absolute path or resolved against a base URL
645645
XCTAssertTrue(
646-
url.relativePath.utf8.first == ._slash || (url.baseURL != nil && url.path().utf8.first == ._slash)
646+
// Using .path to get the absolute path for both the old and new behavior
647+
url.relativePath.utf8.first == ._slash || (url.baseURL != nil && url.path.utf8.first == ._slash)
647648
)
648649

649650
url = URL(filePath: "~", directoryHint: .isDirectory)
650651
XCTAssertTrue(
651-
url.relativePath.utf8.first == ._slash || (url.baseURL != nil && url.path().utf8.first == ._slash)
652+
url.relativePath.utf8.first == ._slash || (url.baseURL != nil && url.path.utf8.first == ._slash)
652653
)
653654
XCTAssertEqual(url.path().utf8.last, ._slash)
654655

655656
url = URL(filePath: "~/")
656657
XCTAssertTrue(
657-
url.relativePath.utf8.first == ._slash || (url.baseURL != nil && url.path().utf8.first == ._slash)
658+
url.relativePath.utf8.first == ._slash || (url.baseURL != nil && url.path.utf8.first == ._slash)
658659
)
659660
XCTAssertEqual(url.path().utf8.last, ._slash)
660661
}
@@ -677,7 +678,12 @@ final class URLTests : XCTestCase {
677678
XCTAssertEqual(url.path(), "/path.foo/")
678679
url.append(path: "/////")
679680
url.deletePathExtension()
681+
#if !FOUNDATION_FRAMEWORK_NSURL
680682
XCTAssertEqual(url.path(), "/path/")
683+
#else
684+
// Old behavior only searches the last empty component, so the extension isn't actually removed
685+
XCTAssertEqual(url.path(), "/path.foo///")
686+
#endif
681687
}
682688

683689
func testURLComponentsPercentEncodedUnencodedProperties() throws {

0 commit comments

Comments
 (0)