getLastSegement
Returns the last segment of a URL path.
Installation
npm install @madeinhaus/utils
Import
import { getLastSegement } from '@madeinhaus/utils';
Parameters
url
(string): The URL to extract the last segment from.
Returns
- (string): The last segment of the URL path.
Usage
import { getLastSegment } from '@madeinhaus/utils';
const url = 'https://example.com/path/to/resource';
const lastSegment = getLastSegment(url); // 'resource'
In this example, we import the getLastSegment
function from the @madeinhaus/utils
package and use it to extract the last segment of a URL path.