/t/XYZ#anchor doesn't work when on the page XYZ

Hello! There’s a problem where if a post links to itself using short link + an anchor (/t/id#anchor) and the link is clicked on the same page, it will redirect to the top rather than the anchor

It’s easier when demonstrated:

Header 1

  1. #header-1 works when tabbed on this thread
  2. https://meta.discourse.org/t/t-xyz-anchor-doesnt-work-when-on-the-page-xyz/225101#header-1-1 works when tabbed on this thread and quoted
  3. https://meta.discourse.org/t/a/225101#header-1-1 works when tabbed on this thread and quoted
  4. https://meta.discourse.org/t/225101#header-1-1 works when not tabbed on this thread
  5. /t/t-xyz-anchor-doesnt-work-when-on-the-page-xyz/225101#header-1-1 works when tabbed on this thread and quoted
  6. /t/a/225101#header-1-1 works when tabbed on this thread and quoted
  7. /t/225101#header-1-1 works when not tabbed on this thread

There’s also two other problems I noticed. All links except the first will reload the page. Links 2, 3, 5 and 6 work but the header is removed from the url after a short amount of time


My original problem was quoting a post which contained a link with only anchor(a link to another section of the same page) would make the anchor relative to the current page rather than the quoted page. If you quote the seven links, the first link will lead to CURRENT PAGE#header-1

I tried the solution in this bug report(attached below). It correctly linked to the page, however, the anchor was not respected