---
title: deleteLastPathComponent()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/url/deletelastpathcomponent()
---

# deleteLastPathComponent()

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

## Declaration

```swift
mutating func deleteLastPathComponent()
```

## 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 do nothing.

## See Also

### Removing path components

- [deletingLastPathComponent()](foundation/url/deletinglastpathcomponent().md)
