From 610b04406f635cfb3c2f958f61ce716de21b04f4 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sun, 03 Dec 2023 00:54:09 +0000
Subject: [PATCH] fix: incorrect test
---
quartz/util/path.test.ts | 2 +-
quartz/util/path.ts | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/quartz/util/path.test.ts b/quartz/util/path.test.ts
index 8bbb58d..18edc94 100644
--- a/quartz/util/path.test.ts
+++ b/quartz/util/path.test.ts
@@ -83,7 +83,7 @@
test("simplifySlug", () => {
asserts(
[
- ["index", ""],
+ ["index", "/"],
["abc", "abc"],
["abc/index", "abc/"],
["abc/def", "abc/def"],
diff --git a/quartz/util/path.ts b/quartz/util/path.ts
index 19aa094..555a191 100644
--- a/quartz/util/path.ts
+++ b/quartz/util/path.ts
@@ -1,5 +1,5 @@
import { slug } from "github-slugger"
-import type { ElementContent, Element as HastElement } from "hast"
+import type { Element as HastElement } from "hast"
// this file must be isomorphic so it can't use node libs (e.g. path)
export const QUARTZ = "quartz"
@@ -25,7 +25,7 @@
/** Shouldn't be a relative path and shouldn't have `/index` as an ending or a file extension. It _can_ however have a trailing slash to indicate a folder path. */
export type SimpleSlug = SlugLike<"simple">
export function isSimpleSlug(s: string): s is SimpleSlug {
- const validStart = !(s.startsWith(".") || s.startsWith("/"))
+ const validStart = !(s.startsWith(".") || (s.length > 1 && s.startsWith("/")))
const validEnding = !(s.endsWith("/index") || s === "index")
return validStart && !_containsForbiddenCharacters(s) && validEnding && !_hasFileExtension(s)
}
--
Gitblit v1.10.0