That's definitely a bug.
There is another bug where link previews weren't rendering anchor links (with # in them) at all, and perhaps this new bug is a result of an attempt to correct the anchor text bug?
You're on mastodon.social so the devs often use it for experimental code which may not work properly. Perhaps this is some of that experimental code?