Skip to content

Commit b68054b

Browse files
authored
Improve detection of site-local path written as external URL (#6118)
1 parent 90502fe commit b68054b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

layouts/_default/_markup/render-link.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@
6767

6868
{{ $isExternal := hasPrefix $url "http" -}}
6969
{{ if $isExternal -}}
70-
{{ if findRE "^https://opentelemetry.io/\\w" $url -}}
71-
{{ warnf "%s: use a local path, not an external URL, for the following reference to a site local page: %s"
72-
.Page.File.Path $url -}}
70+
{{ $matches := findRESubmatch `^https?://(?:www\.)?opentelemetry.io(/?.*)$` $url -}}
71+
{{ $otelIoPath := index (index $matches 0) 1 | default "/" -}}
72+
{{ if $matches -}}
73+
{{ warnf "%s: use a local path '%s' instead of external URL '%s' for reference to site-local page"
74+
.Page.File.Path $otelIoPath $url -}}
7375
{{ else if or
7476
(findRE "^https://github.com/open-telemetry/opentelemetry-specification/(blob|tree)/main/specification/\\w" $url)
7577
(findRE "^https://github.com/open-telemetry/opentelemetry-proto/(blob|tree)/main/docs/specification" $url)

0 commit comments

Comments
 (0)