From 7c65df91a52256c5352a58193b6b20bd29441365 Mon Sep 17 00:00:00 2001 From: nir maoz Date: Wed, 20 Jul 2022 11:23:51 +0300 Subject: [PATCH] feat: add support for authToken prop --- __tests__/image.test.js | 10 ++++++++++ src/Util/cloudinaryReactUtils.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/__tests__/image.test.js b/__tests__/image.test.js index 9c7d1a8..c50ad1b 100644 --- a/__tests__/image.test.js +++ b/__tests__/image.test.js @@ -195,6 +195,16 @@ describe('Image', () => { expect(tag.find('img').prop('src')).toEqual(expected); }); + it('Should support authToken param', function () { + const authToken = 'ip=111.222.111.222~exp=1512982559~acl=%2fimage%2fauthenticated%2f%2a~hmac=b17360091889151e9c2e2a7c713a074fdd29dc4ef1cc2fb897a0764664f3c48d'; + const expected = `http://res.cloudinary.com/demo/image/upload/sample?__cld_token__=${authToken}`; + + const tag = mount( + + ); + + expect(tag.find('img').prop('src')).toEqual(expected); + }); describe('Responsive', () => { const spy = jest.spyOn(console, 'warn').mockImplementation(); diff --git a/src/Util/cloudinaryReactUtils.js b/src/Util/cloudinaryReactUtils.js index 05d42c3..aa2e945 100644 --- a/src/Util/cloudinaryReactUtils.js +++ b/src/Util/cloudinaryReactUtils.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; const { camelCase, withCamelCaseKeys, isEmpty } = Util; // props passed to cloudinary-core but should not be rendered as dom attributes -const CLOUDINARY_REACT_PROPS = ['accessibility', 'breakpoints', 'dataSrc', 'placeholder', 'publicId', 'signature']; +const CLOUDINARY_REACT_PROPS = ['accessibility', 'breakpoints', 'dataSrc', 'placeholder', 'publicId', 'signature', 'authToken']; /** * Convert common video file extensions to mime types