Skip to content

Commit 111268a

Browse files
committed
add error checks and return nil
1 parent 7dc3948 commit 111268a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Foundation/NSURL.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,11 @@ public class NSURL : NSObject, NSSecureCoding, NSCopying {
417417
/* A string constant for the "file" URL scheme. If you are using this to compare to a URL's scheme to see if it is a file URL, you should instead use the NSURL fileURL property -- the fileURL property is much faster. */
418418
public var standardizedURL: NSURL? {
419419
let urlComponent = NSURLComponents(string: relativeString)
420+
421+
guard urlComponent != nil && urlComponent!.path != nil else {
422+
return nil
423+
}
424+
420425
urlComponent!.path = _standardizedURLPath(urlComponent!.path!)
421426
return urlComponent?.URLRelativeToURL(baseURL)
422427
}

0 commit comments

Comments
 (0)