Fix links case sensitivity in path.ts

Taking and improving fix by @valentynkt #1123 and fixing bug #1122 (Case Sensitivity Issue in Markdown Links Leads to 404 Errors)
This commit is contained in:
Antonin Adert 2025-09-07 14:02:52 +02:00 committed by GitHub
parent 42052ebb5f
commit 64dabd2a12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -237,11 +237,12 @@ export function transformLink(src: FullSlug, target: string, opts: TransformOpti
let [targetCanonical, targetAnchor] = splitAnchor(canonicalSlug) let [targetCanonical, targetAnchor] = splitAnchor(canonicalSlug)
if (opts.strategy === "shortest") { if (opts.strategy === "shortest") {
const lowerCaseTargetCanonical = targetCanonical.toLowerCase()
// if the file name is unique, then it's just the filename // if the file name is unique, then it's just the filename
const matchingFileNames = opts.allSlugs.filter((slug) => { const matchingFileNames = opts.allSlugs.filter((slug) => {
const parts = slug.split("/") const parts = slug.split("/")
const fileName = parts.at(-1) const fileName = parts.at(-1)
return targetCanonical === fileName return lowerCaseTargetCanonical === (fileName?.toLowerCase() ?? "")
}) })
// only match, just use it // only match, just use it