Skip to content

Commit

Permalink
Improve detection of site-local path written as external URL (open-te…
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin authored Jan 30, 2025
1 parent 90502fe commit b68054b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@

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

0 comments on commit b68054b

Please sign in to comment.