Skip to content

Commit 638687a

Browse files
committed
修复多级目录时的bug
1 parent 750fd24 commit 638687a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

qcloud_cos/lib/cos.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function upload(filePath, bucket, dstpath, bizattr, callback) {
7373
var isExists = fs.existsSync(filePath);
7474
if (isExists && typeof callback === 'function') {
7575
bucket = bucket.strip();
76-
dstpath = encodeURIComponent(dstpath.strip()).replace('%2F','/');
76+
dstpath = encodeURIComponent(dstpath.strip()).replace(/%2F/g,'/');
7777
var expired = parseInt(Date.now() / 1000) + conf.EXPIRED_SECONDS;
7878
var sign = auth.signMore(bucket, expired);
7979
var url = generateResUrl(bucket, dstpath);
@@ -133,7 +133,7 @@ function upload(filePath, bucket, dstpath, bizattr, callback) {
133133
function upload_slice(filePath, bucket, dstpath, bizattr, slice_size, session, callback) {
134134

135135
bucket = bucket.strip();
136-
dstpath = encodeURIComponent(dstpath.strip()).replace('%2F','/');
136+
dstpath = encodeURIComponent(dstpath.strip()).replace(/%2F/g,'/');
137137
if (typeof bizattr === 'function') {
138138
callback = bizattr;
139139
bizattr = null;
@@ -284,7 +284,7 @@ function upload_data(bucket, dstpath, filePath, offset, length, session, callbac
284284
*/
285285
function statFile(bucket, path, callback) {
286286
bucket = bucket.strip();
287-
path = encodeURIComponent(path.strip()).replace('%2F','/');
287+
path = encodeURIComponent(path.strip()).replace(/%2F/g,'/');
288288
stat(bucket, path, callback);
289289
}
290290
/**
@@ -296,7 +296,7 @@ function statFile(bucket, path, callback) {
296296
*/
297297
function statFolder(bucket, path, callback) {
298298
bucket = bucket.strip();
299-
path = encodeURIComponent(path.strip() + '/').replace('%2F','/');
299+
path = encodeURIComponent(path.strip() + '/').replace(/%2F/g,'/');
300300
stat(bucket, path, callback);
301301
}
302302
/**
@@ -346,7 +346,7 @@ function stat(bucket, path, callback) {
346346
*/
347347
function deleteFile(bucket, path, callback) {
348348
bucket = bucket.strip();
349-
path = encodeURIComponent(path.strip()).replace('%2F','/');
349+
path = encodeURIComponent(path.strip()).replace(/%2F/g,'/');
350350
del(bucket, path, callback);
351351
}
352352
/**
@@ -358,7 +358,7 @@ function deleteFile(bucket, path, callback) {
358358
*/
359359
function deleteFolder(bucket, path, callback) {
360360
bucket = bucket.strip();
361-
path = encodeURIComponent(path.strip()+'/').replace('%2F','/');
361+
path = encodeURIComponent(path.strip()+'/').replace(/%2F/g,'/');
362362
del(bucket, path, callback);
363363
}
364364
/**
@@ -414,7 +414,7 @@ function del(bucket, path, callback) {
414414
*/
415415
function updateFile(bucket, path, bizattr, callback) {
416416
bucket = bucket.strip();
417-
path = encodeURIComponent(path.strip()).replace('%2F','/');
417+
path = encodeURIComponent(path.strip()).replace(/%2F/g,'/');
418418
update(bucket, path, bizattr, callback);
419419
}
420420
/**
@@ -426,7 +426,7 @@ function updateFile(bucket, path, bizattr, callback) {
426426
*/
427427
function updateFolder(bucket, path, bizattr, callback) {
428428
bucket = bucket.strip();
429-
path = encodeURIComponent(path.strip()+'/').replace('%2F','/');
429+
path = encodeURIComponent(path.strip()+'/').replace(/%2F/g,'/');
430430
update(bucket, path, bizattr, callback);
431431
}
432432
/**
@@ -488,7 +488,7 @@ function update(bucket, path, bizattr, callback) {
488488
*/
489489
function list(bucket, path, num, pattern, order, context, callback) {
490490
bucket = bucket.strip();
491-
path = encodeURIComponent(path.strip()+'/').replace('%2F','/');
491+
path = encodeURIComponent(path.strip()+'/').replace(/%2F/g,'/');
492492
listFiles(bucket, path, num, pattern, order, context, callback);
493493
}
494494
/**
@@ -507,7 +507,7 @@ function list(bucket, path, num, pattern, order, context, callback) {
507507
*/
508508
function prefixSearch(bucket, path, prefix, num, pattern, order, context, callback) {
509509
bucket = bucket.strip();
510-
path = encodeURIComponent(path.strip()).replace('%2F','/');
510+
path = encodeURIComponent(path.strip()).replace(/%2F/g,'/');
511511
if (path == '') {
512512
path = prefix;
513513
} else {
@@ -597,7 +597,7 @@ function createFolder(bucket, path, bizattr, callback) {
597597

598598
if (typeof callback === 'function') {
599599
bucket = bucket.strip();
600-
path = encodeURIComponent(path.strip() + '/').replace('%2F','/');
600+
path = encodeURIComponent(path.strip() + '/').replace(/%2F/g,'/');
601601
var expired = parseInt(Date.now() / 1000) + conf.EXPIRED_SECONDS;
602602
var sign = auth.signMore(bucket, expired);
603603
var url = generateResUrl(bucket, path);

qcloud_cos/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qcloud_cos",
3-
"version": "1.0.0",
3+
"version": "1.0.4",
44
"description": "node sdk for qcloud ",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)