ignore url query strings in file path
URL Query strings are included in the file path causing "file not found" errors. This should workaround that. Nothing fancy, just a split on the first ? encountered in the file path.
Better would be something like this:
function defaultFile(url) {
var i = url.indexOf("/", 1) + 1,
j = url.indexOf("?", i + 1);
return decodeURIComponent(url.substring(i, j < 0 ? url.length : j));
}
But of course this is still a pretty poor URL parser, but it’s probably okay for something intended to be overridden.
Best would to add some tests. ;)
Yep, this is a lot nicer. Will update. Introducing tests seems like a separate PR maybe? Got a preference for testing?
That was more a note to myself re. tests. But I’d probably use vows (which is a little long in the tooth but I haven’t bothered to learn a replacement yet) as seen in the smash repo.
Updated with your feedback verbatim.