File tree 3 files changed +50
-1
lines changed
3 files changed +50
-1
lines changed Original file line number Diff line number Diff line change 1
1
## CHANGE LOG
2
+ ## NEXT VERSION
3
+ - 对象存储,修复无法对 key 为空字符串的对象进行操作
4
+
2
5
## 7.8.0
3
6
- 移除不推荐域名,并增加 亚太-首尔 和 华东-浙江2 固定区域
4
7
- RTC,优化请求失败的错误信息
Original file line number Diff line number Diff line change @@ -42,7 +42,11 @@ exports.formatDateUTC = function (date, layout) {
42
42
43
43
// Encoded Entry
44
44
exports . encodedEntry = function ( bucket , key ) {
45
- return exports . urlsafeBase64Encode ( bucket + ( key ? ':' + key : '' ) ) ;
45
+ let strToEncode = bucket ;
46
+ if ( key !== undefined ) {
47
+ strToEncode += ':' + key ;
48
+ }
49
+ return exports . urlsafeBase64Encode ( strToEncode ) ;
46
50
} ;
47
51
48
52
// Get accessKey from uptoken
Original file line number Diff line number Diff line change @@ -328,5 +328,47 @@ describe('test util functions', function () {
328
328
) ;
329
329
}
330
330
} ) ;
331
+
332
+ it ( 'test encodedEntry' , function ( ) {
333
+ const caseList = [
334
+ {
335
+ msg : 'normal' ,
336
+ bucket : 'qiniuphotos' ,
337
+ key : 'gogopher.jpg' ,
338
+ expect : 'cWluaXVwaG90b3M6Z29nb3BoZXIuanBn'
339
+ } ,
340
+ {
341
+ msg : 'key empty' ,
342
+ bucket : 'qiniuphotos' ,
343
+ key : '' ,
344
+ expect : 'cWluaXVwaG90b3M6'
345
+ } ,
346
+ {
347
+ msg : 'key undefined' ,
348
+ bucket : 'qiniuphotos' ,
349
+ key : undefined ,
350
+ expect : 'cWluaXVwaG90b3M='
351
+ } ,
352
+ {
353
+ msg : 'key need replace plus symbol' ,
354
+ bucket : 'qiniuphotos' ,
355
+ key : '012ts>a' ,
356
+ expect : 'cWluaXVwaG90b3M6MDEydHM-YQ=='
357
+ } ,
358
+ {
359
+ msg : 'key need replace slash symbol' ,
360
+ bucket : 'qiniuphotos' ,
361
+ key : '012ts?a' ,
362
+ expect : 'cWluaXVwaG90b3M6MDEydHM_YQ=='
363
+ }
364
+ ] ;
365
+
366
+ for ( let i = 0 ; i < caseList . length ; i ++ ) {
367
+ const actual = qiniu . util . encodedEntry ( caseList [ i ] . bucket , caseList [ i ] . key ) ;
368
+ const expect = caseList [ i ] . expect ;
369
+ const msg = caseList [ i ] . msg ;
370
+ should . equal ( actual , expect , msg ) ;
371
+ }
372
+ } ) ;
331
373
} ) ;
332
374
} ) ;
You can’t perform that action at this time.
0 commit comments