Skip to content

Commit 728b85d

Browse files
eyalktCloudinarystrausr
authored andcommitted
Fix named transformations with spaces
1 parent da4841e commit 728b85d

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

lib-es5/utils/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ function url(public_id) {
874874
var prefix = unsigned_url_prefix(public_id, cloud_name, private_cdn, cdn_subdomain, secure_cdn_subdomain, cname, secure, secure_distribution);
875875
var resultUrl = [prefix, resource_type, type, signature, transformation, version, public_id].filter(function (part) {
876876
return part != null && part !== '';
877-
}).join('/');
877+
}).join('/').replace(' ', '%20');
878878
if (sign_url && !isEmpty(auth_token)) {
879879
auth_token.url = urlParse(resultUrl).path;
880880
var token = generate_token(auth_token);

lib/uploader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ function parseResult(buffer, res) {
336336
let result = '';
337337
try {
338338
result = JSON.parse(buffer);
339-
if(result.error && !result.error.name) {
339+
if (result.error && !result.error.name) {
340340
result.error.name = "Error";
341341
}
342342
} catch (jsonError) {

lib/utils/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ function url(public_id, options = {}) {
872872
);
873873
let resultUrl = [prefix, resource_type, type, signature, transformation, version, public_id].filter(function (part) {
874874
return (part != null) && part !== '';
875-
}).join('/');
875+
}).join('/').replace(' ', '%20');
876876
if (sign_url && !isEmpty(auth_token)) {
877877
auth_token.url = urlParse(resultUrl).path;
878878
let token = generate_token(auth_token);

test/utils_spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@ describe("utils", function () {
527527
transformation: ["blip", "blop"],
528528
}, `http://res.cloudinary.com/${cloud_name}/image/upload/t_blip.blop/test`, {});
529529
});
530+
it("should support named transformations with spaces", function () {
531+
test_cloudinary_url("test", {
532+
transformation: "blip blop",
533+
}, `http://res.cloudinary.com/${cloud_name}/image/upload/t_blip%20blop/test`, {});
534+
});
530535
it("should support base transformation", function () {
531536
test_cloudinary_url("test", {
532537
transformation: {

0 commit comments

Comments
 (0)