`var queryString = url.substring(url.indexOf('?') + 1) || "";`

The `| ""` should take care of that case.