Skip to content

Commit d0b79fc

Browse files
committed
x_val can be not a func
1 parent 4b17f71 commit d0b79fc

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

demo/js/qiniu.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,12 @@ function QiniuJsSDK() {
347347
var x_vars = op.x_vars;
348348
if (x_vars !== undefined && typeof x_vars === 'object') {
349349
for (var x_key in x_vars) {
350-
if (x_vars.hasOwnProperty(x_key) && typeof x_vars[x_key] === 'function') {
351-
multipart_params_obj['x:' + x_key] = x_vars[x_key](up, file);
350+
if (x_vars.hasOwnProperty(x_key)) {
351+
if (typeof x_vars[x_key] === 'function') {
352+
multipart_params_obj['x:' + x_key] = x_vars[x_key](up, file);
353+
} else if (typeof x_vars[x_key] === 'string') {
354+
multipart_params_obj['x:' + x_key] = x_vars[x_key];
355+
}
352356
}
353357
}
354358
}
@@ -496,11 +500,16 @@ function QiniuJsSDK() {
496500
}
497501

498502
var x_vars = op.x_vars,
503+
x_val = '',
499504
x_vars_url = '';
500505
if (x_vars !== undefined && typeof x_vars === 'object') {
501506
for (var x_key in x_vars) {
502-
if (x_vars.hasOwnProperty(x_key) && typeof x_vars[x_key] === 'function') {
503-
var x_val = that.URLSafeBase64Encode(x_vars[x_key](up, file));
507+
if (x_vars.hasOwnProperty(x_key)) {
508+
if (typeof x_vars[x_key] === 'function') {
509+
x_val = that.URLSafeBase64Encode(x_vars[x_key](up, file));
510+
} else if (typeof x_vars[x_key] === 'string') {
511+
x_val = that.URLSafeBase64Encode(x_vars[x_key]);
512+
}
504513
x_vars_url += '/x:' + x_key + '/' + x_val;
505514
}
506515
}

src/qiniu.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,12 @@ function QiniuJsSDK() {
347347
var x_vars = op.x_vars;
348348
if (x_vars !== undefined && typeof x_vars === 'object') {
349349
for (var x_key in x_vars) {
350-
if (x_vars.hasOwnProperty(x_key) && typeof x_vars[x_key] === 'function') {
351-
multipart_params_obj['x:' + x_key] = x_vars[x_key](up, file);
350+
if (x_vars.hasOwnProperty(x_key)) {
351+
if (typeof x_vars[x_key] === 'function') {
352+
multipart_params_obj['x:' + x_key] = x_vars[x_key](up, file);
353+
} else if (typeof x_vars[x_key] === 'string') {
354+
multipart_params_obj['x:' + x_key] = x_vars[x_key];
355+
}
352356
}
353357
}
354358
}
@@ -496,11 +500,16 @@ function QiniuJsSDK() {
496500
}
497501

498502
var x_vars = op.x_vars,
503+
x_val = '',
499504
x_vars_url = '';
500505
if (x_vars !== undefined && typeof x_vars === 'object') {
501506
for (var x_key in x_vars) {
502-
if (x_vars.hasOwnProperty(x_key) && typeof x_vars[x_key] === 'function') {
503-
var x_val = that.URLSafeBase64Encode(x_vars[x_key](up, file));
507+
if (x_vars.hasOwnProperty(x_key)) {
508+
if (typeof x_vars[x_key] === 'function') {
509+
x_val = that.URLSafeBase64Encode(x_vars[x_key](up, file));
510+
} else if (typeof x_vars[x_key] === 'string') {
511+
x_val = that.URLSafeBase64Encode(x_vars[x_key]);
512+
}
504513
x_vars_url += '/x:' + x_key + '/' + x_val;
505514
}
506515
}

0 commit comments

Comments
 (0)