NullPointerException fix in the case of malformed URLs