JQuery changing class of element with id or class based on page url/name
<p>Here is my code</p>

<p>HTML</p>

<pre><code>&lt;div id="header-content" class="header-content"&gt;...&lt;/div&gt;
</code></pre>

<p>Jquery</p>

<pre><code>    $( document ).ready(function() {



      var loc = window.location.href; // returns the full URL
      if(/$/.test(loc)) { // If Empty or if just home URL
        $('#header-content').addClass('home-page');
        //Remove All Other Classes
        $('#header-content').removeClass('start-here');
        $('#header-content').removeClass('work-with-me');
      }
      if(/start-here$/.test(loc)) { // if page = root/start-here/
        $('#header-content').addClass('start-here');
        //Remove All Other Classes
        $('#header-content').removeClass('home-page');
        $('#header-content').removeClass('work-with-me');
      }
      if(/work-with-me$/.test(loc)) { // if page = root/work-with-me/
        $('#header-content').addClass('work-with-me');
        //Remove All Other Classes
        $('#header-content').removeClass('home-page');
        $('#header-content').removeClass('start-here');
      }


    });
</code></pre>

<p>URL Example: 
<a href="http://www.somedomain.com/the-page/" rel="nofollow">http://www.somedomain.com/the-page/</a></p>

<p>What I'd like to do is have the script identify the text "the-page" in the url and if it's a match assign the class. As you can see in my sample jquery code, I'm trying to assign classes to the home page, start-here page and work-with-me page. </p>

<p>I'm not sure how to modify the above Jquery so it will work with the URL Example format. </p>

<p>As well how would I detect if it was the index page and the URL looked like this: <a href="http://www.somedomain.com/" rel="nofollow">http://www.somedomain.com/</a> with no page name on the end?</p>