From d1593758046b1df1dc9c496ccc2cd07fef284231 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Tue, 8 Aug 2023 21:31:36 -0700 Subject: [PATCH] fix getFileExtension missing numeric extensions (e.g. mp4) --- quartz/components/ContentMeta.tsx | 4 +--- quartz/path.test.ts | 1 + quartz/path.ts | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/quartz/components/ContentMeta.tsx b/quartz/components/ContentMeta.tsx index 007ce3e6..715c0f46 100644 --- a/quartz/components/ContentMeta.tsx +++ b/quartz/components/ContentMeta.tsx @@ -13,9 +13,7 @@ export default (() => { } segments.push(timeTaken) - return ( -

{segments.join(", ")}

- ) + return

{segments.join(", ")}

} else { return null } diff --git a/quartz/path.test.ts b/quartz/path.test.ts index 614273f8..480493ef 100644 --- a/quartz/path.test.ts +++ b/quartz/path.test.ts @@ -145,6 +145,7 @@ describe("transforms", () => { ["/content/index.md", "content/index"], ["content/cool.png", "content/cool"], ["index.md", "index"], + ["test.mp4", "test"], ["note with spaces.md", "note-with-spaces"], ], path.slugifyFilePath, diff --git a/quartz/path.ts b/quartz/path.ts index 9af5c7bf..e410771a 100644 --- a/quartz/path.ts +++ b/quartz/path.ts @@ -221,7 +221,7 @@ function _hasFileExtension(s: string): boolean { } function _getFileExtension(s: string): string | undefined { - return s.match(/\.[A-Za-z]+$/)?.[0] + return s.match(/\.[A-Za-z0-9]+$/)?.[0] } function _isRelativeSegment(s: string): boolean {