title: How to know if a URL is decoded/encoded?
body: <p>I am using Javascript method <code>decodeURIComponent</code> to decode an encoded URL. Now I am having an issue, that sometimes the URL is get encoded twice during redirection between servers, sometimes it is encoded only once. </p>
  
  <p>I want to check that if the URL is still encoded after calling the method <code>decodeURIComponent</code>. How can I do that? Any pointer would be very helpful to me.</p>
  
  <h2>Update - 1</h2>
  
  <p>If I recursively call a method and check that if the given URL still contains "%", if it contains "%" then decode it and call the method again; and if not return it to the caller, will that work?</p>
  
  <h2>Update - 2</h2>
  
  <p>For my case I have:</p>
  
  <pre><code>callBackUrl=http%253A%252F%252Fadbc.com%252FPOSM%252Fapp%252Fpages%252Fadf.task-flow%253Fadf.tfDoc%253D%25252FWEB-INF%25252Ftask-flows%25252Fcatalog-edit-task-flow.xml%2526adf.tfId%253Dcatalog%2526_adf.ctrl-state%253Db9akorh22_9%2526articleReference%253D10C00135%2526previousView%253Dcatalog-home%2526fromUCM%253Dtrue%2526articleType%253Dposm%2526developer%253Dcentral
  </code></pre>
  
  <p>Now I am taking the value of the callBackUrl in my js method, then decoding it and firing <code>window.open()</code> with that decoded URL. the parameters are same and it has:</p>
  
  <ul>
  <li>adf.tfDoc</li>
  <li>adf.tfId</li>
  <li>articleReference</li>
  <li>previousView</li>
  <li>fromUCM</li>
  <li>articleType</li>
  <li>developer</li>
  </ul>
  
  <p>Parameters into it. So I know there is no query string like <code>value="%.."</code>.</p>
  
  <h2>Update - 3</h2>
  
  <p>I have written the following method:</p>
  
  <pre><code>var decodeURLRecursively = function(url) {
      if(url.indexOf('%') != -1) {
          return decodeURLRecursively(decodeURIComponent(url));
      }
  
      return url;
  }
  </code></pre>