Would it not be better here to check if url is a function? If it is, then we know that url is the callback, and can shift the args appropriately.