This is not right. `encodeURI()` will not encode: `~!@#$&*()=:/,;?+'` which means stuff like `?` will produce broken URIs.