Skip to content

useLocation().hash doesn't include leading # #6686

@Dubzer

Description

@Dubzer

Which project does this relate to?

Router

Describe the bug

useLocation().hash doesn't include leading #

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-ml6mqcym?file=src%2Froutes%2Fechohash.tsx&preset=node

Steps to Reproduce the Bug or Issue

  1. https://stackblitz.com/edit/tanstack-router-ml6mqcym?file=src%2Froutes%2Fechohash.tsx&preset=node
  2. navigate to /echohash#123

Expected behavior

the docs say:

  /**
   * The hash of the location, including the leading hash character.
   */
  hash: string;

so the shown text is supposed to be #123
it is also the behavior defined by WHATWG URL spec

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.160.2
  • OS: MacOS
  • Browser: Chrome
  • Browser Version: 144.0.7559.133

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions