Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
jbaudanza opened this Issue · 3 comments

2 participants

Jonathan Baudanza Oliver Nightingale
Jonathan Baudanza

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.

Jonathan Baudanza

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

Oliver Nightingale
Owner

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.

Oliver Nightingale
Owner

Should be solved in the latest release

Oliver Nightingale olivernn closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.