Q:

Check for duplicate val in url string

I've url string and I want to know if it contains duplicate like port more then one time for example in this case 54001 or 77777 is exist more than one time?
I've lo-dash and underscore js
http://gr-t6fa45e73.go.grp.corp:54001/oauth/authorize?response_type=code&redirect_uri=http%3A%2F%2Fro-d3ma32e85.mo.grp.corp%3A77777%2Flogin%2Fcallback&client_id=zs6.node&test=54001

A:

Something like this? This pure JS function try to search url params that matches with url ports

function search() {
    var url = unescape(document.getElementById("url").innerHTML); 
    var patternPort = /:\d+/g;    
    var ports = url.match(patternPort);

    for (i=0; i<ports.length; i++){
       var patternParam= new RegExp("=" + ports[i].substr(1), 'g');
       if(url.match(patternParam)){
          alert(ports[i].substr(1) + " is repeated");
       }
    }        
}
<pre id="url">http://gr-t6fa45e73.go.grp.corp:54001/oauth/authorize?response_type=code&redirect_uri=http%3A%2F%2Fro-d3ma32e85.mo.grp.corp%3A77777%2Flogin%2Fcallback&client_id=zs6.node&test=54001</pre>
<button onclick="search()">Search repeated ports on params</button>

