File tree Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -424,7 +424,12 @@ proto._getUserAgent = function _getUserAgent() {
424
424
plat = 'Node.js ' + process . version . slice ( 1 ) + ' on ' + process . platform + ' ' + process . arch ;
425
425
}
426
426
427
- return sdk + ' ' + plat ;
427
+ return this . _checkUserAgent ( sdk + ' ' + plat ) ;
428
+ } ;
429
+
430
+ proto . _checkUserAgent = function _checkUserAgent ( ua ) {
431
+ var userAgent = ua . replace ( / \u03b1 / , "alpha" ) . replace ( / \u03b2 / , "beta" ) ;
432
+ return userAgent ;
428
433
} ;
429
434
430
435
/*
Original file line number Diff line number Diff line change @@ -409,7 +409,12 @@ proto._getUserAgent = function _getUserAgent() {
409
409
plat = 'Node.js ' + process . version . slice ( 1 ) + ' on ' + process . platform + ' ' + process . arch ;
410
410
}
411
411
412
- return sdk + ' ' + plat ;
412
+ return this . _checkUserAgent ( sdk + ' ' + plat ) ;
413
+ } ;
414
+
415
+ proto . _checkUserAgent = function _checkUserAgent ( ua ) {
416
+ var userAgent = ua . replace ( / \u03b1 / , "alpha" ) . replace ( / \u03b2 / , "beta" ) ;
417
+ return userAgent ;
413
418
} ;
414
419
415
420
/*
Original file line number Diff line number Diff line change @@ -307,6 +307,14 @@ describe('browser', function () {
307
307
'aliyun-sdk-js/' + pkg . version + ' ' + platform . description ) ) ;
308
308
} ) ;
309
309
310
+ it ( 'should check beta or alpha User-Agent' , function ( ) {
311
+ var store = oss ( ossConfig ) ;
312
+ var ua_beta = store . _checkUserAgent ( 'aliyun-sdk-nodejs/4.12.2 Node.js β-8.4.0 on darwin x64' ) ;
313
+ assert . equal ( ua_beta , 'aliyun-sdk-nodejs/4.12.2 Node.js beta-8.4.0 on darwin x64' ) ;
314
+ var ua_alpha = store . _checkUserAgent ( 'aliyun-sdk-nodejs/4.12.2 Node.js α-8.4.0 on darwin x64' ) ;
315
+ assert . equal ( ua_alpha , 'aliyun-sdk-nodejs/4.12.2 Node.js alpha-8.4.0 on darwin x64' ) ;
316
+ } ) ;
317
+
310
318
311
319
it ( 'should trim access id/key' , function ( ) {
312
320
var store = oss ( {
Original file line number Diff line number Diff line change @@ -287,6 +287,14 @@ describe('test/client.test.js', function () {
287
287
'aliyun-sdk-nodejs/' + pkg . version + ' Node.js ' + process . version . slice ( 1 ) ) ) ;
288
288
} ) ;
289
289
290
+ it ( 'should check beta or alpha User-Agent' , function ( ) {
291
+ var store = oss ( config ) ;
292
+ var ua_beta = store . _checkUserAgent ( 'aliyun-sdk-nodejs/4.12.2 Node.js β-8.4.0 on darwin x64' ) ;
293
+ assert . equal ( ua_beta , 'aliyun-sdk-nodejs/4.12.2 Node.js beta-8.4.0 on darwin x64' ) ;
294
+ var ua_alpha = store . _checkUserAgent ( 'aliyun-sdk-nodejs/4.12.2 Node.js α-8.4.0 on darwin x64' ) ;
295
+ assert . equal ( ua_alpha , 'aliyun-sdk-nodejs/4.12.2 Node.js alpha-8.4.0 on darwin x64' ) ;
296
+ } ) ;
297
+
290
298
it ( 'should check browser and version' , function * ( ) {
291
299
var store = oss ( config ) ;
292
300
assert ( store . checkBrowserAndVersion ( "" , "" ) ) ;
You can’t perform that action at this time.
0 commit comments