From 0e4352ffdbe761c8c6b6c0ef1df63094206954e6 Mon Sep 17 00:00:00 2001 From: Paul Gottschling Date: Wed, 1 Nov 2023 10:52:41 -0400 Subject: [PATCH] Get the test to pass --- server/remark-includes.ts | 10 ++++++++-- uvu-tests/remark-includes.test.ts | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/server/remark-includes.ts b/server/remark-includes.ts index b308257a6a..35321a8605 100644 --- a/server/remark-includes.ts +++ b/server/remark-includes.ts @@ -287,8 +287,14 @@ const handleURLPath = ( ) { const href = node.url; - // Ignore non-strings, absolute paths, or web URLs - if (typeof href !== "string" || href[0] === "/" || /^http/.test(href)) { + // Ignore non-strings, absolute paths, web URLs, and links consisting only + // of anchors (these will end up pointing to the containing page). + if ( + typeof href !== "string" || + href[0] === "/" || + /^http/.test(href) || + href[0] === "#" + ) { return href; } diff --git a/uvu-tests/remark-includes.test.ts b/uvu-tests/remark-includes.test.ts index 3904be577e..1a68a8eae2 100644 --- a/uvu-tests/remark-includes.test.ts +++ b/uvu-tests/remark-includes.test.ts @@ -610,7 +610,8 @@ This is a [link to an anchor](#this-is-a-section). ## This is a section. -This is content within the section.` +This is content within the section. +` ); } );