From 1b0e887df5c55642c74d177d03a0d5126aa21870 Mon Sep 17 00:00:00 2001 From: Karim H Date: Fri, 21 Mar 2025 11:34:17 -0400 Subject: [PATCH] feat(path): add function to check if a file path is absolute --- quartz/util/path.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/quartz/util/path.ts b/quartz/util/path.ts index 0681fae72..86388a33e 100644 --- a/quartz/util/path.ts +++ b/quartz/util/path.ts @@ -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 {