How to check the url with javascript / jquery even if their is a trailing slash?
<p>I have two panels with a list of links inside of them being used as a sidebar on a blog. One of the panels will expand if it contains a link to the current url.</p>

<p>The problem is if a trailing slash is added at the end of the current url it no longer works. How could I achieve this so it works regardless of whether or not the url has a trailing slash?</p>

<p>Here's the current code I'm using:</p>

<pre><code>jQuery('.list-group-item a[href$="' + window.location.pathname + '"]').addClass("active").parents('.panel .panel-heading a').collapse('show');
</code></pre>

<p>And here's a live example:</p>

<p><a href="http://s.codepen.io/bootstrapped/debug/jqWXmM" rel="nofollow">http://s.codepen.io/bootstrapped/debug/jqWXmM</a></p>

<p>But if you visit this it doesn't work (note the trailing slash):</p>

<p><a href="http://s.codepen.io/bootstrapped/debug/jqWXmM/" rel="nofollow">http://s.codepen.io/bootstrapped/debug/jqWXmM/</a></p>