can.route.pushstate mishandles hash fragments #259

Closed
talentedmrjones opened this Issue Jan 28, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@talentedmrjones

For links containing hash fragments like

<a href="/articles/17#references">

The URL gets set to /articles/17%23references and window.location.hash == ''

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Jan 28, 2013

Contributor

Can you create a fiddle showing this because I'm not understanding what you mean exactly.

Sent from my iPhone

On Jan 28, 2013, at 9:55 AM, Richard Jones notifications@github.com wrote:

For links containing hash fragments like

The URL gets set to /articles/17%23references and window.location.hash == ''


Reply to this email directly or view it on GitHub.

Contributor

justinbmeyer commented Jan 28, 2013

Can you create a fiddle showing this because I'm not understanding what you mean exactly.

Sent from my iPhone

On Jan 28, 2013, at 9:55 AM, Richard Jones notifications@github.com wrote:

For links containing hash fragments like

The URL gets set to /articles/17%23references and window.location.hash == ''


Reply to this email directly or view it on GitHub.

@talentedmrjones

This comment has been minimized.

Show comment
Hide comment
@talentedmrjones

talentedmrjones Jan 28, 2013

I take that back. I'm sorry the hash symbol being URL encoded was from a change I made to the core of the plugin.

Look here:https://github.com/bitovi/canjs/blob/master/route/pushstate/pushstate.js#L42

You will see this.pathname+this.search

window.location.hash is not included at all. Therefore the pushstate code does not allow for links that contain hashes. I'd like to use pushstate but also need to support hashes so I can jump to specific places in the page based on window.location.hash.

I've tried changing that line to this.pathname+this.hash+this.search but that ended up URL encoding the # and left window.location.hash empty.

I take that back. I'm sorry the hash symbol being URL encoded was from a change I made to the core of the plugin.

Look here:https://github.com/bitovi/canjs/blob/master/route/pushstate/pushstate.js#L42

You will see this.pathname+this.search

window.location.hash is not included at all. Therefore the pushstate code does not allow for links that contain hashes. I'd like to use pushstate but also need to support hashes so I can jump to specific places in the page based on window.location.hash.

I've tried changing that line to this.pathname+this.hash+this.search but that ended up URL encoding the # and left window.location.hash empty.

@ghost ghost assigned justinbmeyer Sep 20, 2013

justinbmeyer added a commit that referenced this issue Sep 21, 2013

fixes #259 by allowing clicked links with hashes to pass the hash th…
…rough to the setURL, some strange things needed to be done to get all the frameworks to work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment