Skip to content

Commit

Permalink
Add a sentence on how to fix the external URI warning (#142)
Browse files Browse the repository at this point in the history
Closes #140

## Changes

Add a sentence on how to fix the warning, explaining where to add the
base domain.

```shell
Warning: External URI 'https://docs.elastic.dev/migration/site-level/content#asciidoctor-conf-yml' is not allowed. Add 'elastic.dev' to the 'external_hosts' list in /Users/jcal/Projects/docs-builder/docs/source/docset.yml to allow links to this domain.
   ┌─[/Users/jcal/Projects/docs-builder/docs/source/testing/index.md]
   │
   │
   └─
```

## Notes

The warning is missing the actual markdown line where the error is
happening. (See example from
#140)
I saw the same behavior with @Mpdreamz when he demoed the app to me.
  • Loading branch information
reakaleek authored Jan 7, 2025
1 parent 260bac3 commit cc8fdf5
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice)
{
var baseDomain = string.Join('.', uri.Host.Split('.')[^2..]);
if (!context.Configuration.ExternalLinkHosts.Contains(baseDomain))
processor.EmitWarning(line, column, length, $"external URI: {uri} ");
{
processor.EmitWarning(
line,
column,
length,
$"External URI '{uri}' is not allowed. Add '{baseDomain}' to the " +
$"'external_hosts' list in {context.Configuration.SourceFile} to " +
"allow links to this domain.");
}
return match;
}

Expand Down

0 comments on commit cc8fdf5

Please sign in to comment.