title: Encoding single quote with node
body: <p>We are using cloudfront to cache our resource. When we have to invalidate cache, we are making request to cloudfront API to invalidate cache where we need to send URL to invalidate. Due to single quote in URL, cloudfront is throwing us error of invalidation path error.</p>
  <p>Our URL is /autocomplete/posts/2?term=13 Scary Podcasts That'll Keep You Up All Night&amp;pagesize=25&amp;pagenumber=1&amp;excludeexpiredposts=true</p>
  <p>We are using encodeURI(url) which give us following</p>
  <p>&quot;/autocomplete/posts/2?term=13%20Scary%20Podcasts%20That'll%20Keep%20You%20Up%20All%20Night&amp;pagesize=25&amp;pagenumber=1&amp;excludeexpiredposts=true&quot; - Not valid for CloudFront</p>
  <p>If we use encodeURIComponent, it give us following
  &quot;%2Fautocomplete%2Fposts%2F2%3Fterm%3D13%20Scary%20Podcasts%20That'll%20Keep%20You%20Up%20All%20Night%26pagesize%3D25%26pagenumber%3D1%26excludeexpiredposts%3Dtrue&quot; - Not valid for Cloudfront</p>
  <p>If we use escape, it gives us following;
  &quot;/autocomplete/posts/2%3Fterm%3D13%20Scary%20Podcasts%20That%27ll%20Keep%20You%20Up%20All%20Night%26pagesize%3D25%26pagenumber%3D1%26excludeexpiredposts%3Dtrue&quot; - VALID FOR CLOUDFRONT</p>
  <p>But escape is deprecated and not recommended. Can you please advise how do we fix this ?</p>