changed domain-routing logic to consider length of path AND domain when determining best match between multiple results