Rearrange code

Return early on getHost function to avoid having all the logic inside an if block, and put more clearly when is strict slash going to be matched