Skip to content

Commit 2960712

Browse files
authored
Merge pull request #572 from shibomb/fix/fix-internal-link-without-siteurl
Internal links (starting with #) no longer add the site URL.
2 parents 47fb24f + e1184b3 commit 2960712

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/middleware.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ export const ensureCorrectLocalePrefixesInHtmlLinks = (
6565
$("a").each(function () {
6666
let href = $(this).attr("href");
6767
// Skip if href is undefined, an external link, or written with a dot slash
68-
if (!href || href.startsWith("http") || href.startsWith("./")) return;
68+
if (
69+
!href ||
70+
href.startsWith("http") ||
71+
href.startsWith("./") ||
72+
href.startsWith("#")
73+
)
74+
return;
6975

7076
const startsWithLocale = nonDefaultSupportedLocales.some(
7177
(locale) => href && href.startsWith(`/${locale}/`),

0 commit comments

Comments
 (0)