@@ -36,7 +36,7 @@ public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProc
3636 // Find links that are nested inside other links.
3737 $ nestedLinks = \array_filter (
3838 $ elements ,
39- static fn (\DOMElement $ element ) => DOMUtil::hasParent ($ element , 'a ' ),
39+ static fn (\DOMElement $ element ) => DOMUtil::hasParent ($ element , 'a ' ),
4040 );
4141
4242 if ($ nestedLinks !== []) {
@@ -66,18 +66,22 @@ static function (\DOMElement $element) use ($nestedLinks) {
6666
6767 if ($ href ->getScheme () !== 'mailto ' ) {
6868 if (ApplicationHandler::getInstance ()->isInternalURL ($ href ->__toString ())) {
69- if ($ href ->getHost () === '' ) {
70- // `withScheme()` implicitly adds `localhost`
71- // https://www.woltlab.com/community/thread/302070-link-ohne-protokoll-zeigt-auf-localhost/
72- $ href = $ href ->withHost (ApplicationHandler::getInstance ()->getDomainName ());
73- }
69+ // Check if the links is nothing more but a named anchor.
70+ // See https://www.woltlab.com/community/thread/311519-anchor-verlinkung-im-editor-ignoriert-domain-pfad/
71+ if (!Uri::isSameDocumentReference ($ href )) {
72+ if ($ href ->getHost () === '' ) {
73+ // `withScheme()` implicitly adds `localhost`
74+ // https://www.woltlab.com/community/thread/302070-link-ohne-protokoll-zeigt-auf-localhost/
75+ $ href = $ href ->withHost (ApplicationHandler::getInstance ()->getDomainName ());
76+ }
7477
75- $ href = $ href ->withScheme (RouteHandler::secureConnection () ? 'https ' : 'http ' );
78+ $ href = $ href ->withScheme (RouteHandler::secureConnection () ? 'https ' : 'http ' );
7679
77- $ element ->setAttribute (
78- 'href ' ,
79- $ href ->__toString (),
80- );
80+ $ element ->setAttribute (
81+ 'href ' ,
82+ $ href ->__toString (),
83+ );
84+ }
8185 } else {
8286 /** @var HtmlOutputNodeProcessor $htmlNodeProcessor */
8387 self ::markLinkAsExternal ($ element , $ htmlNodeProcessor ->getHtmlProcessor ()->enableUgc );
0 commit comments