[utils] Extract sanitize_url routine