File tree Expand file tree Collapse file tree 3 files changed +50
-1
lines changed Expand file tree Collapse file tree 3 files changed +50
-1
lines changed Original file line number Diff line number Diff line change 11## CHANGE LOG
2+ ## NEXT VERSION
3+ - 对象存储,修复无法对 key 为空字符串的对象进行操作
4+
25## 7.8.0
36- 移除不推荐域名,并增加 亚太-首尔 和 华东-浙江2 固定区域
47- RTC,优化请求失败的错误信息
Original file line number Diff line number Diff line change @@ -42,7 +42,11 @@ exports.formatDateUTC = function (date, layout) {
4242
4343// Encoded Entry
4444exports . 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 ) ;
4650} ;
4751
4852// Get accessKey from uptoken
Original file line number Diff line number Diff line change @@ -328,5 +328,47 @@ describe('test util functions', function () {
328328 ) ;
329329 }
330330 } ) ;
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+ } ) ;
331373 } ) ;
332374} ) ;
You can’t perform that action at this time.
0 commit comments