ensure inputs to URI#encode are strings, fixes #498