title: How to remove trailing slash from window.location.pathname
body: <p>I have the following code that's allowing me to switch between desktop and mobile versions of my website,</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera 
  Mini/i.test(navigator.userAgent) ) {
  window.location = "http://m.mysite.co.uk";
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I recently realised all that does is send everyone to the homepage of the site. I dug around a bit and figured I could redirect specific pages to the mobile version by amending the above to,</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
   window.location = "http://m.mysite.co.uk" +  window.location.pathname;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>The only problem with that is the trailing slash on the end of the URL path is causing the URL to not be recognised.</p>
  
  <p>Is there a way of removing that trailing slash within the Javascript?</p>
  
  <p>The site is on an old Windows 2003 server so it's IIS6 in case anyone was going to suggest the URL Rewrite module.</p>
  
  <p>Thanks for any advice offered.</p>