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

Sanity checking when building a Davis.Request object from JSON #10

Closed
jbaudanza opened this issue Sep 3, 2011 · 3 comments
Closed

Sanity checking when building a Davis.Request object from JSON #10

jbaudanza opened this issue Sep 3, 2011 · 3 comments

Comments

@jbaudanza
Copy link
Contributor

I've been seeing some error reports from inside of Davis.Request:

Uncaught TypeError: Cannot call method 'split' of undefined

which corresponds to this line:

this.queryString = raw.fullPath.split("?")[1];

I've only seen these errors come from Hoptoad. I haven't been able to reproduce locally from inside my app.

The only code path I can imagine this happening is when a Davis.Request object is constructed from event.state on a popstate event.

I've noticed this exact error happening in the test suite inside of the "binding and triggering the pop state event" test. Davis.Request doesn't know how to rebuild itself from "foo".

In general, I don't like writing defensive code, but I wonder if it makes sense to do some sanity checking on the data inside of event.state.

@jbaudanza
Copy link
Contributor Author

I should add, these errors appear to be coming from Chrome, where the hashRouting extension should be disabled.

@olivernn
Copy link
Owner

olivernn commented Sep 5, 2011

In the latest release, which I'll push later today, I have made sure that there are defaults when creating a Davis.Request, this should stop these errors showing up. I've also been a bit more careful about the data that we pull out of the state object, making sure it is something that Davis put in the state object before using that data to build a request. Hopefully this will mean this error goes away now.

@olivernn
Copy link
Owner

olivernn commented Sep 7, 2011

Should be solved in the latest release

@olivernn olivernn closed this as completed Sep 7, 2011
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

2 participants