File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
Sources/FoundationEssentials/URL
Tests/FoundationEssentialsTests Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -2155,14 +2155,6 @@ extension URL {
21552155 isDirectory = filePath. utf8. last == slash
21562156 }
21572157
2158- if !isAbsolute {
2159- #if !NO_FILESYSTEM
2160- filePath = filePath. standardizingPath
2161- #else
2162- filePath = filePath. removingDotSegments
2163- #endif
2164- }
2165-
21662158 #if os(Windows)
21672159 // Convert any "\" back to "/" before storing the URL parse info
21682160 filePath = filePath. replacing ( UInt8 ( ascii: " \\ " ) , with: UInt8 ( ascii: " / " ) )
Original file line number Diff line number Diff line change @@ -352,6 +352,23 @@ final class URLTests : XCTestCase {
352352 }
353353 }
354354
355+ func testURLRelativeDotDotResolution( ) throws {
356+ let baseURL = URL ( filePath: " /docs/src/ " )
357+ var result = URL ( filePath: " ../images/foo.png " , relativeTo: baseURL)
358+ #if FOUNDATION_FRAMEWORK_NSURL
359+ XCTAssertEqual ( result. path, " /docs/images/foo.png " )
360+ #else
361+ XCTAssertEqual ( result. path ( ) , " /docs/images/foo.png " )
362+ #endif
363+
364+ result = URL ( filePath: " /../images/foo.png " , relativeTo: baseURL)
365+ #if FOUNDATION_FRAMEWORK_NSURL
366+ XCTAssertEqual ( result. path, " /../images/foo.png " )
367+ #else
368+ XCTAssertEqual ( result. path ( ) , " /../images/foo.png " )
369+ #endif
370+ }
371+
355372 func testAppendFamily( ) throws {
356373 let base = URL ( string: " https://www.example.com " ) !
357374
You can’t perform that action at this time.
0 commit comments