Update more clean way to check if link is dir.