Check that uri is a URI or string before converting.