feat(path): add function to check if a file path is absolute

This commit is contained in:
Karim H 2025-03-21 11:34:17 -04:00
parent 248ad2c4ed
commit 1b0e887df5

View File

@ -15,6 +15,11 @@ export function isFilePath(s: string): s is FilePath {
return validStart && _hasFileExtension(s)
}
export function isAbsoluteFilePath(s: string): s is FilePath {
const parsedUrl = new URL(s)
return !parsedUrl.protocol
}
/** Cannot be relative and may not have leading or trailing slashes. It can have `index` as it's last segment. Use this wherever possible is it's the most 'general' interpretation of a slug. */
export type FullSlug = SlugLike<"full">
export function isFullSlug(s: string): s is FullSlug {