Encode `query` before using in `fragment`.

`navigate` expects fragments to be encoded so that they
can be meaningfully compared to the fragment retrieved
from `window.location`.