rafgraph / react-router-hash-link

Hash link scroll functionality for React Router
https://react-router-hash-link.rafgraph.dev
MIT License
732 stars 62 forks source link

Supplying only a hash includes the pathname #96

Open thany opened 2 years ago

thany commented 2 years ago

Suppose this link on the, I dunno, the /contact page:

<HashLink to="#top">Top</HashLink>

This will produce:

<a href="/contact#top">Top</a>

What's that /contact doing there? It's not supposed to be there. I didn't specify a link to the current page, but only to a hash.

To reproduce:

  1. Go to the demo.
  2. Scroll down to the Top of Page link, and inspect its attributes.
  3. Observe its href attribute being /page#top.
  4. Now go to the source.
  5. Scroll down and find the same link.
  6. Observe how it only has to="#top" and nothing else as far as urls are concerned.
blackr1234 commented 2 years ago

Looks like this issue is no longer there.