SIGABRT: URL without path on empty "appendingPathComponent"

Originator:flavio
Number:rdar://30511326 Date Originated:2017-02-14
Status:Open Resolved:
Product:iOS + SDK / Foundation Product Version:Xcode 8.2 running Swift 3
Classification:Bug Reproducible:Always
 
Area:
Foundation

Summary:
If one sends an empty string when "appendingPathComponent" to a URL without a path and trailing slash, the compiler throws SIGABRT.

Steps to Reproduce:
1 - Create an URL object without a path and trailing slash, e.g. "http://apple.com"
2 - url.lastPathComponent should be an empty string
3 - Call url.appendingPathComponent(url.lastPathComponent)
4 - SIGABRT will happen

Expected Results:
Should behave the same as calling url.appendingPathComponent("")


Actual Results:
SIGABRT

Version:
Xcode 8.2 (8C38) running Swift 3.0.2

Notes:
I've attached a playground with code that triggers the bug.

Configuration:
MacBook Pro Retina 13" Late 2013

Attachments:
'URL BUG.playground.zip' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!