fragment(percentEncoded:)
Returns the fragment component of the URL, optionally removing any percent-encoding.
Declaration
func fragment(percentEncoded: Bool = true) -> String?Parameters
- percentEncoded:
A Boolean value that indicates whether the URL percent-encodes any unreserved characters. Defaults to
true.
Return Value
The fragment component of the URL, optionally percent-encoding any unreserved characters.
Discussion
The system doesn’t allow certain characters in the URL fragment component, so URL percent-encodes those characters to create a valid URL. Calling this function with percentEncoded = false removes any percent-encoding and returns the unencoded fragment.
If the URL doesn’t contain a fragment component according to RFC 3986, this function returns nil.