---
title: "user(percentEncoded:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/url/user(percentencoded:)"
---

# user(percentEncoded:)

Returns the user component of the URL, optionally removing any percent-encoding.

## Declaration

```swift
func user(percentEncoded: Bool = true) -> String?
```

## Parameters

- `percentEncoded`: A Boolean value that indicates whether the URL percent-encodes any unreserved characters. Defaults to true.

## Return Value

Return Value The system doesn’t allow certain characters in the URL user 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 user. If the URL doesn’t contain a user component according to RFC 3986, this function returns nil.

## See Also

### Accessing the parts of a URL

- [fragment(percentEncoded:)](foundation/url/fragment(percentencoded:).md)
- [fragment](foundation/url/fragment.md)
- [host(percentEncoded:)](foundation/url/host(percentencoded:).md)
- [host](foundation/url/host.md)
- [lastPathComponent](foundation/url/lastpathcomponent.md)
- [path(percentEncoded:)](foundation/url/path(percentencoded:).md)
- [path](foundation/url/path.md)
- [password(percentEncoded:)](foundation/url/password(percentencoded:).md)
- [password](foundation/url/password.md)
- [pathComponents](foundation/url/pathcomponents.md)
- [pathExtension](foundation/url/pathextension.md)
- [port](foundation/url/port.md)
- [query(percentEncoded:)](foundation/url/query(percentencoded:).md)
- [query](foundation/url/query.md)
- [scheme](foundation/url/scheme.md)
