diff --git a/Sources/Foundation/NSURL.swift b/Sources/Foundation/NSURL.swift index 706001ba1c..2c751b355c 100644 --- a/Sources/Foundation/NSURL.swift +++ b/Sources/Foundation/NSURL.swift @@ -1451,15 +1451,9 @@ open class NSURLComponents: NSObject, NSCopying { return NSRange(_CFURLComponentsGetRangeOfFragment(_components)) } - /// Returns an array of query items for this `URLComponents`, in the order in which they appear in the original query string. - /// - /// Each `URLQueryItem` represents a single key-value pair, - /// - /// Note that a name may appear more than once in a single query string, so the name values are not guaranteed to be unique. If the `URLComponents` has an empty query component, returns an empty array. If the `URLComponents` has no query component, returns nil. - /// - /// The setter combines an array containing any number of `URLQueryItem`s, each of which represents a single key-value pair, into a query string and sets the `URLComponents` query property. Passing an empty array sets the query component of the `URLComponents` to an empty string. Passing nil removes the query component of the `URLComponents`. - /// - /// - note: If a name-value pair in a query is empty (i.e. the query string starts with '&', ends with '&', or has "&&" within it), you get a `URLQueryItem` with a zero-length name and a nil value. If a query's name-value pair has nothing before the equals sign, you get a zero-length name. If a query's name-value pair has nothing after the equals sign, you get a zero-length value. If a query's name-value pair has no equals sign, the query name-value pair string is the name and you get a nil value. + // The getter method that underlies the queryItems property parses the query string based on these delimiters and returns an NSArray containing any number of NSURLQueryItem objects, each of which represents a single key-value pair, in the order in which they appear in the original query string. Note that a name may appear more than once in a single query string, so the name values are not guaranteed to be unique. If the NSURLComponents object has an empty query component, queryItems returns an empty NSArray. If the NSURLComponents object has no query component, queryItems returns nil. + // The setter method that underlies the queryItems property combines an NSArray containing any number of NSURLQueryItem objects, each of which represents a single key-value pair, into a query string and sets the NSURLComponents' query property. Passing an empty NSArray to setQueryItems sets the query component of the NSURLComponents object to an empty string. Passing nil to setQueryItems removes the query component of the NSURLComponents object. + // Note: If a name-value pair in a query is empty (i.e. the query string starts with '&', ends with '&', or has "&&" within it), you get a NSURLQueryItem with a zero-length name and and a nil value. If a query's name-value pair has nothing before the equals sign, you get a zero-length name. If a query's name-value pair has nothing after the equals sign, you get a zero-length value. If a query's name-value pair has no equals sign, the query name-value pair string is the name and you get a nil value. open var queryItems: [URLQueryItem]? { get { // This CFURL implementation returns a CFArray of CFDictionary; each CFDictionary has an entry for name and optionally an entry for value @@ -1471,8 +1465,8 @@ open class NSURLComponents: NSObject, NSCopying { return (0.. () throws -> Void)] { return [ ("test_queryItems", test_queryItems), @@ -476,7 +258,6 @@ class TestURLComponents: XCTestCase { ("test_createURLWithComponents", test_createURLWithComponents), ("test_path", test_path), ("test_percentEncodedPath", test_percentEncodedPath), - ("test_percentEncodedQueryItems", test_percentEncodedQueryItems), ] } }