Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for authToken prop #252

Merged
1 commit merged into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions __tests__/image.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<Image cloudName='demo' publicId='sample' authToken={authToken} />
);

expect(tag.find('img').prop('src')).toEqual(expected);
});
describe('Responsive', () => {
const spy = jest.spyOn(console, 'warn').mockImplementation();

Expand Down
2 changes: 1 addition & 1 deletion src/Util/cloudinaryReactUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down