Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does pushy not work with # fragment urls? #14

Open
afhammad opened this issue Apr 3, 2016 · 10 comments
Open

Does pushy not work with # fragment urls? #14

afhammad opened this issue Apr 3, 2016 · 10 comments

Comments

@afhammad
Copy link

afhammad commented Apr 3, 2016

fragments after the # don't seem to be supported. Is there a reason for that?

i.e if an href contains "/#some/path" the match function will only be passed "/".

@gfrivolt
Copy link

I miss the part behind the hash too. What's the reason it's not taken into account?

@thomasmulvaney
Copy link
Member

Hash URLs are used as a way of faking a page change. Now days with modern browsers supporting HTML5 push state this hack is no longer required. Pushy wraps up this newer API into a familiar ClojureScript library. There is currently no plan to support this older approach of history accounting in Pushy.

@ieure
Copy link

ieure commented Nov 19, 2016

How do you suggest single-page apps handle navigation? If the whole thing is served from a single app.html file, lack of fragment support means URLs can't be shared — they'd refer to a path which doesn't exist.

I think that fixing this would require making the webserver return the same payload for any request, which limits the deployability — I can't just plop the file on S3 (or another dumb HTTP object store) and have it work. If you need special support on the backend, this defeats the purpose of writing a SPA, at least for me.

@thomasmulvaney
Copy link
Member

@ieure We will think about supporting this. For the apps we have written, we have not needed this kind of hash bang routing. The point you make about dumb servers is one we never considered. We will look into implementing this. Naturally, a PR would be very welcome 😄

@ieure
Copy link

ieure commented Nov 19, 2016

Thanks, I'll see if I can put something together.

@dustingetz
Copy link

dustingetz commented Jul 18, 2017

Url fragments are used for more things than hacks, for example table of contents links:

<a href="#my-heading">navigate to Heading</a>
<a name="my-heading">Heading</a>

@dustingetz
Copy link

dustingetz commented Jul 18, 2017

I fixed it by using the Modnakasta fork to process url fragments, providing a custom :processable-url? predicate to ignore urls with fragments (thus not calling preventDefault), and also passing an :identify-fn to drop tokens with fragments (thus not dispatching on navigate). I had to make pushy.core/processable-url? not private so i could call it from userland.

(pushy/pushy
  (fn [page-path] ...)
  identity
  :processable-url? #(and (pushy.core/processable-url? %)
                          (not (.hasFragment %)))
  :identity-fn #(if-not (string/includes? % "#") %))

@Ionshard
Copy link

Ionshard commented Aug 25, 2017

I would absolutely love to see this feature as it's causing me some issues. Shouldn't be too hard considering there are two PRs out that solve this issue already. PR #25 and PR #26.

Thank you!

@jwr
Copy link

jwr commented Feb 12, 2018

Ok, that might explain why links (with anchors) to specific parts of my user's guide were not working. As @dustingetz wrote, hash fragments are useful in a number of scenarios, not just for faking page changes. In my case, I have a number of server-side rendered pages which are then used ("hydrated") with React-based client-side JavaScript.

@dijonkitchen
Copy link

Any update on this or all those PRs (#21, #24, #25)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants