You brought in `URLUtil`, but never use it.  You probably should.
It's probably a good idea to use a library instead of writing these utilities ourselves (I used the `URI` class recently for similar reasons)