uploadcare / uploadcare-ruby

Ruby API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
https://uploadcare.com
MIT License
39 stars 28 forks source link

Update signed URLs implementation to work with ~ and , #138

Closed rsedykh closed 4 months ago

rsedykh commented 1 year ago

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.

vipulnsward commented 6 months ago

Related: https://github.com/uploadcare/uploadcare-ruby/issues/167

vipulnsward commented 4 months ago

Works now with https://github.com/uploadcare/uploadcare-ruby/commit/6aa292df27e1f46b518e3f8b11c9de33a7fc6c99