Skip to content

Commit 4b7ee5a

Browse files
committed
Merge pull request #300 from seabaylea/NSURLComponent
Fix failure in setter for NSURLComponents.port
2 parents 566ffd7 + 7530dcb commit 4b7ee5a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CoreFoundation/URL.subproj/CFURLComponents.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ CF_EXPORT Boolean _CFURLComponentsSetPort(CFURLComponentsRef components, CFNumbe
655655
} else {
656656
components->_portComponent = NULL;
657657
}
658-
components->_passwordComponentValid = true;
658+
components->_portComponentValid = true;
659659
__CFUnlock(&components->_lock);
660660
return true;
661661
}

TestFoundation/TestNSURL.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ class TestNSURLComponents : XCTestCase {
423423
static var allTests: [(String, TestNSURLComponents -> () throws -> Void)] {
424424
return [
425425
("test_string", test_string),
426+
("test_port", test_portSetter),
426427
]
427428
}
428429

@@ -435,5 +436,15 @@ class TestNSURLComponents : XCTestCase {
435436
XCTAssertEqual(components.string!, expectedString, "should be the expected string (\(components.string!) != \(expectedString))")
436437
}
437438
}
439+
440+
func test_portSetter() {
441+
let urlString = "http://myhost.mydomain.com"
442+
let port: NSNumber = 8080
443+
let expectedString = "http://myhost.mydomain.com:8080"
444+
let url = NSURLComponents(string: urlString)
445+
url!.port = port
446+
let receivedString = url!.string
447+
XCTAssertEqual(receivedString, expectedString, "expected \(expectedString) but received \(receivedString)")
448+
}
438449

439450
}

0 commit comments

Comments
 (0)