---
title: deletingLastPathComponent()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/url/deletinglastpathcomponent()
---

# deletingLastPathComponent()

Returns a URL constructed by removing the last path component of self.

## Declaration

```swift
func deletingLastPathComponent() -> URL
```

## Discussion

Discussion This function may either remove a path component or append /... If the URL has an empty path (e.g., http://www.example.com), then this function will return the URL unchanged.

## See Also

### Removing path components

- [deleteLastPathComponent()](foundation/url/deletelastpathcomponent().md)
