Skip to content

Commit 5f383d9

Browse files
committed
fix(transforms): allow uppercased params in transform
1 parent 8649634 commit 5f383d9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/lib/api/transform.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ describe('transform', () => {
103103
assert.equal(result, expected);
104104
});
105105

106+
106107
it('should handle storage with url handle', () => {
107108
const storeAlias = 'https://test.com/file.js';
108109

@@ -181,6 +182,13 @@ describe('transform', () => {
181182
assert.equal(result, `${cdnUrl}/store=filename:test.jpg,path:"test/path"/fakelink`)
182183
});
183184

185+
it('should handle upper cased path', () => {
186+
const options = { filename: 'test.jpg' , path: 'tEsT/path'};
187+
const result = transform(url, { store: options});
188+
189+
assert.equal(result, `${cdnUrl}/store=filename:test.jpg,path:"tEsT/path"/fakelink`)
190+
});
191+
184192

185193
describe('blackwhite', () => {
186194
it('should construct valid parameters', () => {

src/lib/api/transform.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,12 @@ const escapeValue = (value: any): any => {
494494
* @param options Transformation options
495495
*/
496496
export const transform = (session: Session, url: string, options: TransformOptions = {}): string => {
497-
options = toSnakeCase(valuesToLowerCase(options));
497+
options = toSnakeCase(options);
498498

499499
const validate = getValidator(TransformSchema);
500500

501-
if (!validate(options)) {
501+
// use lower case only for validation
502+
if (!validate(valuesToLowerCase(JSON.parse(JSON.stringify(options)))) ) {
502503
throw new FilestackError('Validation error', validate.errors);
503504
}
504505

0 commit comments

Comments
 (0)