I'm not sure of a good way to word this, it looks pretty horrible no matter how it's written

The algorithm is basically, "if we don't start with hashPrefix at all, and we have a ? after the hash, treat it as a query, otherwise it's an invalid hash prefix"