Skip to Content
PureHTMLdocs
Transformers

removeLastPathSection

Strip the trailing path segment from a URL.

The removeLastPathSection transformer strips the last directory or slug segment from a URL path while preserving query parameters and hashes.

Basic Usage

{ selector: a, items: { transform: [attr(href), removeLastPathSection] } }

Preserving Search Query Parameters

selector: a
transform: [attr(href), removeLastPathSection]

On this page