uploadcare-ruby icon indicating copy to clipboard operation
uploadcare-ruby copied to clipboard

Update signed URLs implementation to work with ~ and ,

Open rsedykh opened this issue 2 years ago • 0 comments

Currently URL like /cd334b26-c641-4393-bcce-b5041546430d~11/nth/1/-/crop/250x250/1000,1000/ won't work when signing a URL, because Akamai escape some symbols.

We use tildas in group URLs, and commas in operations like crop and overlay.

Here is a code snippet how it should work:

function escapeEarly(path) {
  return encodeURIComponent(path)
    .replace(/[~'*]/g, function (c) {
      return '%' + c.charCodeAt(0).toString(16);
    })
    .replace(/%../g, function (match) {
      return match.toLowerCase();
    })
    .replace(/%2c/g, ',')
    .replace(/%20/g, '%2520');
}

Test environment — https://uploadcare.com/docs/security/secure-delivery/#test-environment.

rsedykh avatar Nov 21 '23 15:11 rsedykh