Remove slash at the end of path in if