fix: use links with leading slash as-is

Links that started with a slash were being prepended the URL hostname
and rendered as absolute links before. This caused our link checker to
miss broken links that contained a leading slash.

This change fixes this issue by rendering links with a leading slash as-is,
without modification.

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2023-09-29 21:06:55 +02:00
parent 1598774c9c
commit 2eb97d7fe7
1 changed files with 2 additions and 2 deletions

View File

@ -12,8 +12,8 @@
></a
>
{{- else if (strings.HasPrefix $url "/") -}}
{{/* absolute link, use absURL */}}
<a class="link" href="{{ absURL $url }}">{{ .Text | safeHTML }}</a>
{{/* absolute link, use url as-is */}}
<a class="link" href="{{ $url }}">{{ .Text | safeHTML }}</a>
{{- else -}}
{{/* check if the file links to index.md */}}
{{- if (strings.FindRE `([^_]|^)index.md` $url 1) -}}