Add option to AutolinkOptions to allow domains that don't contain a ., e.g. localhost #728

Closed
opened 2026-01-29 14:43:59 +00:00 by claunia · 3 comments
Owner

Originally created by @JamesNK on GitHub (Mar 15, 2025).

I found https://github.com/xoofx/markdig/issues/827 which has people wanting localhost autolinked. It was closed without helping people support this scenario.

If autolinking http://localhost isn't enabled by default, there should be an option on AutolinkOptions to allow it. The alternative requires folks to copy and past all of the autolink code and modify it allow more URLs.

Originally created by @JamesNK on GitHub (Mar 15, 2025). I found https://github.com/xoofx/markdig/issues/827 which has people wanting localhost autolinked. It was closed without helping people support this scenario. If autolinking http://localhost isn't enabled by default, there should be an option on `AutolinkOptions` to allow it. The alternative requires folks to copy and past all of the autolink code and modify it allow more URLs.
claunia added the enhancementPR Welcome! labels 2026-01-29 14:43:59 +00:00
Author
Owner

@xoofx commented on GitHub (Mar 15, 2025):

If autolinking http://localhost isn't enabled by default, there should be an option on AutolinkOptions to allow it.

Agreed. The option can be added.

@xoofx commented on GitHub (Mar 15, 2025): > If autolinking http://localhost isn't enabled by default, there should be an option on `AutolinkOptions` to allow it. Agreed. The option can be added.
Author
Owner

@JamesNK commented on GitHub (Mar 16, 2025):

I can make a PR. What kind of option do you want? A bool flag to allow single label host name?

var options = new AutolinkOptions { AllowSingleLabelHostName = true };
@JamesNK commented on GitHub (Mar 16, 2025): I can make a PR. What kind of option do you want? A bool flag to allow single label host name? ```cs var options = new AutolinkOptions { AllowSingleLabelHostName = true }; ```
Author
Owner

@xoofx commented on GitHub (Mar 16, 2025):

I can make a PR. What kind of option do you want? A bool flag to allow single label host name?

Maybe AllowHostNameWithoutPeriod? (And add in the API XML an example betwteen http:mydomain.com vs http://localhost)

@xoofx commented on GitHub (Mar 16, 2025): > I can make a PR. What kind of option do you want? A bool flag to allow single label host name? Maybe `AllowHostNameWithoutPeriod`? (And add in the API XML an example betwteen `http:mydomain.com` vs `http://localhost`)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#728