Changing part of a URL and appending the URL based on specific characters jQuery
<p>I need to look at a href in a page and see if a certain bit of text is in the URL, if it is i need to change it to something else, then append a location to the end. </p>

<p>if the link contains "ice/app?service=page&amp;page=probrowse"</p>

<p>ex: <a href="http://www.google.com/" rel="nofollow">http://www.google.com/</a><strong>ice/app?service=page&amp;page=probrowse</strong>&amp;cat=1&amp;year=2011</p>

<p>I need to change it to "club/probrowse.htm?"</p>

<p>ex: <a href="http://www.google.com/club/probrowse.htm?cat=1&amp;year=2011" rel="nofollow">http://www.google.com/club/probrowse.htm?cat=1&amp;year=2011</a></p>

<p>I am currently running the script below which takes into consideration ? and &amp; in the URL and appending a location to the href. </p>

<pre><code>&lt;script type="text/javascript"&gt;
    jQuery(document).ready(function(){  
        jQuery('a').attr('href', function() {
                return (this.href.indexOf("?") &gt;= 0) ? this.href + "&amp;location=/abc/123" : this.href + "?location=/abc/123";
           });

    });
&lt;/script&gt;
</code></pre>

<p>I ran into some other bumps due to the fact I am ingesting information from another site and need to make some minor URL changes.</p>

<p>The overall goal is to change </p>

<p>google.com/ice/app?service=page&amp;page=probrowse&amp;cat=1&amp;year=2011</p>

<p>into</p>

<p>google.com/club/probrowse.htm?cat=1&amp;year=2011&amp;location=/abc/123</p>
