title: Check if a link is internal or external
body: <p>Hello i am building something like a webspider in C#. In my research i came across a problem were i need to determen if a link is internal or external, inbound or outbound. So i needed to create a function to do the work for me. So i came up with the following function but i am not sure if its the best possible algorythm in order to accomplish that task. So i would like your opinions upon this problem.</p>
  
  <p>I asume that links with no http:// or https:// in front of the link are internal
  and if i have a domain <a href="http://www.blahblah.com" rel="noreferrer">http://www.blahblah.com</a> then a link like test should still be internal despite the fact that it has http:// in front, but a link like <a href="http://www.somethingelse.com/?var1=http://www.blahblah.com/test" rel="noreferrer">http://www.somethingelse.com/?var1=http://www.blahblah.com/test</a> is external sto i am checking the first letters only.</p>
  
  <pre><code>private Boolean checklinkifinternal(String link)
          {
              Boolean isinternal = false;
  
              if (link.IndexOf("http://") == 0 || link.IndexOf("https://") == 0)
              {
                  //Then probably external
                  if (link.IndexOf("http://" + UrlName) == 0 || link.IndexOf("https://" + UrlName) == 0 || link.IndexOf("http://www." + UrlName) == 0 || link.IndexOf("https://www." + UrlName) == 0)
                  {
                      isinternal = true;
                  }
              }
              else
              {
                  isinternal = true;
              }
  
              return isinternal;
          }
  </code></pre>