Fix notices in UrlUtils.

This adds checks to ensure we're only accessing indexes within `$parts` that exist.