title: reverse function to encodeURI()
body: <p>I'm writing a component that integrate between two 3rd-party libraries.</p>
  
  <p>Gets a URL from the first library, and pass it to the second library.</p>
  
  <p>The URL i get is in the format of:</p>
  
  <p><a href="https://xxxxx.s3.amazonaws.com/xxxx_xx_xx/xxxx_xx_xx/xxxxxxxx/g_19743dff-0931-40c4-ac5a-10fd1150bda4/x/xxxxxxxx_xxxx_xx_xx_xx_xx_xx_xxxx_xxx_xxx_xxxxxxxxxx.jpg?AWSAccessKeyId=AKIAJFACFRGCGV7RPFKQ&amp;Expires=1445259633&amp;Signature=RD35q%2BlEc4Lkn5ppfM2QTKsDCTo%3D" rel="nofollow">https://xxxxx.s3.amazonaws.com/xxxx_xx_xx/xxxx_xx_xx/xxxxxxxx/g_19743dff-0931-40c4-ac5a-10fd1150bda4/x/xxxxxxxx_xxxx_xx_xx_xx_xx_xx_xxxx_xxx_xxx_xxxxxxxxxx.jpg?AWSAccessKeyId=AKIAJFACFRGCGV7RPFKQ&amp;Expires=1445259633&amp;Signature=RD35q%2BlEc4Lkn5ppfM2QTKsDCTo%3D</a></p>
  
  <p>meaning it include signs like "=" and "+" in encoded format.</p>
  
  <p>When I pass it to the second library as-is, the library failed to download the file.
  From the source of that library I see that it tries to perform 'encode(url)' before downloading the file, which cause it to be encoded again with no need.</p>
  
  <p>I tried decoding the URL before transferring it to the second library (with <em>decodeURI</em> or <em>decodeURIComponent</em>), so it will then encode it and successfully download the file, but encode() doesn't encode all chars, it has some reserved-char (like '+' and '='), so the result url wasn't end up the same as the original.</p>
  
  <p>To sum-up my question:</p>
  
  <p>Assuming i don't have any control over the code of the 2 libraries, given 'encodedUrl', how can I implement 'myFunc(str)' such that:</p>
  
  <pre><code>encodeURI(myFunc(encodedUrl)) === encodedUrl
  </code></pre>
  
  <p>for every url possible.</p>