localhost autolinks #708

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

Originally created by @joriszwart on GitHub (Nov 25, 2024).

It looks like auto linking doesn't work for localhost (and other single part domains):

http://localhost:5000 # not rendered
http://localhost.dev:5000 # rendered
http://example:5000 # not rendered

This may be intentional, but I have not found anything like this in the autolink extension.

Originally created by @joriszwart on GitHub (Nov 25, 2024). It looks like auto linking doesn't work for localhost (and other single part domains): ``` http://localhost:5000 # not rendered http://localhost.dev:5000 # rendered http://example:5000 # not rendered ``` This may be intentional, but I have not found anything like this in the autolink extension.
claunia added the question label 2026-01-29 14:43:35 +00:00
Author
Owner

@dmitry-azaraev commented on GitHub (Nov 28, 2024):

This looks like method IsValidDomain requires to have at least two segments (i did not know if it is exist other assumptions about in other places).

49cf59b819/src/Markdig/Extensions/AutoLinks/AutoLinkParser.cs (L167)

@dmitry-azaraev commented on GitHub (Nov 28, 2024): This looks like method IsValidDomain requires to have at least two segments (i did not know if it is exist other assumptions about in other places). https://github.com/xoofx/markdig/blob/49cf59b819a53d3a1d356ce0dfdce014a48fd91f/src/Markdig/Extensions/AutoLinks/AutoLinkParser.cs#L167
Author
Owner

@snnz commented on GitHub (Nov 28, 2024):

GFM spec says:

An extended www autolink will be recognized when the text www. is found followed by a valid domain. A valid domain consists of segments of alphanumeric characters, underscores (_) and hyphens (-) separated by periods (.). There must be at least one period ...

and then:

An extended url autolink will be recognised when one of the schemes http://, or https://, followed by a valid domain

One would think that "There must be at least one period" is related to the definition of the valid domain, but it seems to apply to the www autolinks only.

@snnz commented on GitHub (Nov 28, 2024): GFM spec says: > An [extended www autolink](https://github.github.com/gfm/#extended-www-autolink) will be recognized when the text www. is found followed by a [valid domain](https://github.github.com/gfm/#valid-domain). A [valid domain](https://github.github.com/gfm/#valid-domain) consists of segments of alphanumeric characters, underscores (_) and hyphens (-) separated by periods (.). **There must be at least one period** ... and then: > An [extended url autolink](https://github.github.com/gfm/#extended-url-autolink) will be recognised when one of the schemes http://, or https://, followed by a [valid domain](https://github.github.com/gfm/#valid-domain) One would think that "There must be at least one period" is related to the definition of the valid domain, but it seems to apply to the **www** autolinks only.
Author
Owner

@joriszwart commented on GitHub (Feb 21, 2025):

So it's according to specifications.

@joriszwart commented on GitHub (Feb 21, 2025): So it's according to specifications.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#708