Fix a bad check for valid URIs

our check for bad URLs was broken by an impossible if conditional. Now it's fixed (with tests).