mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Add getPathPartsFromAstroRequest helper
This commit is contained in:
parent
1df930059e
commit
e34e661f86
1 changed files with 12 additions and 0 deletions
|
|
@ -37,3 +37,15 @@ export function getSiteUrl () {
|
||||||
|
|
||||||
throw new Error('Could not find site URL')
|
throw new Error('Could not find site URL')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPathPartsFromAstroRequest ( AstroRequest ) {
|
||||||
|
// Parse the request url
|
||||||
|
const requestUrl = new URL( AstroRequest.url )
|
||||||
|
|
||||||
|
const pathParts = requestUrl.pathname
|
||||||
|
.replace(/^\/+/, '') // Trim slashes from the beginning
|
||||||
|
.replace(/\/+$/, '') // Trim slashes from the end
|
||||||
|
.split('/')
|
||||||
|
|
||||||
|
return pathParts
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue