Skip to content
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
3 changes: 2 additions & 1 deletion lib-es5/utils/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ var CONDITIONAL_OPERATORS = {
"*": "mul",
"/": "div",
"+": "add",
"-": "sub"
"-": "sub",
"^": "pow"
};

var SIMPLE_PARAMS = [["audio_codec", "ac"], ["audio_frequency", "af"], ["bit_rate", 'br'], ["color_space", "cs"], ["default_image", "d"], ["delay", "dl"], ["density", "dn"], ["duration", "du"], ["end_offset", "eo"], ["fetch_format", "f"], ["gravity", "g"], ["page", "pg"], ["prefix", "p"], ["start_offset", "so"], ["streaming_profile", "sp"], ["video_codec", "vc"], ["video_sampling", "vs"]];
Expand Down
2 changes: 1 addition & 1 deletion lib-es5/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function normalize_expression(expression) {
return expression;
}

var operators = "\\|\\||>=|<=|&&|!=|>|=|<|/|-|\\+|\\*";
var operators = "\\|\\||>=|<=|&&|!=|>|=|<|/|-|\\^|\\+|\\*";
var operatorsPattern = "((" + operators + ")(?=[ _]))";
var operatorsReplaceRE = new RegExp(operatorsPattern, "g");
expression = expression.replace(operatorsReplaceRE, function (match) {
Expand Down
1 change: 1 addition & 0 deletions lib/utils/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const CONDITIONAL_OPERATORS = {
"/": "div",
"+": "add",
"-": "sub",
"^": "pow",
};

let SIMPLE_PARAMS = [
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function normalize_expression(expression) {
return expression;
}

const operators = "\\|\\||>=|<=|&&|!=|>|=|<|/|-|\\+|\\*";
const operators = "\\|\\||>=|<=|&&|!=|>|=|<|/|-|\\^|\\+|\\*";
const operatorsPattern = "((" + operators + ")(?=[ _]))";
const operatorsReplaceRE = new RegExp(operatorsPattern, "g");
expression = expression.replace(operatorsReplaceRE, match => CONDITIONAL_OPERATORS[match]);
Expand Down
13 changes: 13 additions & 0 deletions test/utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,19 @@ describe("utils", function () {
},
}, `http://res.cloudinary.com/${cloud_name}/image/upload/c_scale,l_text:Arial_18:$(start)Hello%20$(name)$(ext)%252C%20%24%28no%20%29%20%24%28%20no%29$(end)/sample`, {});
});
it("should support power operator", function () {
var options, t;
options = {
transformation: [
{
$small: 150,
$big: "$small ^ 1.5",
},
],
};
t = cloudinary.utils.generate_transformation_string(options);
expect(t).to.eql("$big_$small_pow_1.5,$small_150");
});
});
describe("text", function () {
var text_encoded, text_layer;
Expand Down