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
Is it possible to have an option that detects HTML5 History or falls back to hash automatically? #20
Comments
To quote the react-router docs:
|
Ok, those are valid points, but that could be a developer's choice. We can just document the concerns and make it an option. For those browsers that would use HTML5 History then they will use hashes appropriately. It's only for the old browsers like IE9 where they will be stuck using the hashes for routes. I'd live with the risk that the IE9 and current browsers can't share URL's since over time there will be less and less of those browsers. While I wish everyone would ditch the old browsers, for some sites that is not yet an option. So we'd be stuck using hashes for everyone while most people could use HTML5 History API. It's a balance of trying to move things forward (using latest API's) while not totally breaking things for old browsers. Yes, they might not have the full experience (sharing URL's might not work right), but they'd be able to use the site to some effect. You are basically going to force me to create a 5 line project that wraps this one so I can detect HTML5 History before calling the appropriate routing method. :-( |
From reading the React Router FAQ you linked |
But when a user with a modern browser shares a URL with someone who doesn't have a modern browser, everything breaks.
@jeffbski All we're forcing you to do is decide what your URLs look like up front. When you're building your app, decide which browsers you want to support. If you need to support IE < 10, then use hash history. Otherwise, use real URLs. |
FWIW it is indeed possible to support both, but it's a bit more complicated that one would initially think. I wrote it back in the day for Ember and it went through many iterations of bug fixes and design choices. If anyone cares to port it.. http://www.slideshare.net/jayphelps/auto-location I don't have a need for this ability these days so I can't spend the cycles, sorry! |
@jayphelps how do you distinguish between an app that uses browser history with a real hash and an app that uses hash history? Seems impossible. Both will have hashes, but they are interpreted differently. |
@mjackson Not 100% sure which case you're referring to, but perhaps you're talking about how to distinguish between a hashed URL that needs transformation to a clean history URL and treated as a route, e.g. It's currently possible in Ember to have doubled up hashes as well, though no built-in utility exists to extract these. e.g. Also, just to clarify, when you boot up the URLs are normalized to the supporting feature. So history supported browsers will transformed hashed routes immediately to pretty history URLs and hash-only browsers will transform pretty history URLs to the hashed version. This is so the user's URL is consistent while navigating around and so shared links don't contain two different routes in them making it confusing to users. |
Thanks for the explanation, @jayphelps. We currently force all hash history URLs to begin with a slash, so we'd probably have to sacrifice that feature in order to take the route you describe here. |
@mjackson Yup, hmmm..but that doesn't really seem like a true feature to me? Seems like a shortcut to make the code easier to reason at the expense of disallowing hash metadata. e.g. |
Is it possible to have an option that detects HTML5 History API or falls back to hash automatically?
I would think that would be what most people would prefer to do these days. I think ember has that type of functionality with its "auto" location option.
http://emberjs.com/api/classes/Ember.Location.html
The text was updated successfully, but these errors were encountered: