Skip to content

[SR-2981] Adding empty array to URLComponents queryItems adds a unnecessary '?' to the end of the URL #4314

@swift-ci

Description

@swift-ci
Previous ID SR-2981
Radar None
Original Reporter madsbogeskov (JIRA User)
Type Bug
Status Closed
Resolution Won't Do

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee mattrajca (JIRA)
Priority Medium

md5: d0bedad00d4be1f3856ee128bfd0a58c

Issue Description:

var components = URLComponents(string: "https://www.lego.com")!
print(components.url!)
// this prints "https://www.lego.com\n"
components.queryItems = []
print(components.url!)
// this prints "https://www.lego.com?\n"
components.queryItems = nil
print(components.url!)
// this prints "https://www.lego.com\n"

There is no reason that there should be any difference between the empty and nil array in this case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions