This repository was archived by the owner on May 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed
Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -150,11 +150,10 @@ const Upload = function Upload(bucketName, opts) {
150150
151151 if ( ! this . opts . url && this . opts . aws . region === 'us-east-1' ) {
152152 this . opts . url = `https://s3.amazonaws.com/${ bucketName } /` ;
153+ } else if ( ! this . opts . url && this . opts . aws . region === 'cn-north-1' ) {
154+ this . opts . url = `https://s3.${ this . opts . aws . region } .amazonaws.com/${ bucketName } /` ;
153155 } else if ( ! this . opts . url ) {
154- this . opts . url = [
155- 'https://s3-' , this . opts . aws . region ,
156- '.amazonaws.com/' , bucketName , '/' ,
157- ] . join ( '' ) ;
156+ this . opts . url = `https://s3-${ this . opts . aws . region } .amazonaws.com/${ bucketName } /` ;
158157 }
159158
160159 this . _randomPath = this . opts . randomPath || uuid ;
Original file line number Diff line number Diff line change @@ -132,15 +132,17 @@ describe('Upload', () => {
132132 url : 'https://s3.amazonaws.com/myBucket/' ,
133133 } ) ;
134134 } ) ;
135- it ( 'sets default url based on AWS region' , ( ) => {
136- upload = new Upload ( 'b' , {
137- aws : {
138- region : 'my-region-1' ,
139- } ,
140- } ) ;
135+
136+ it ( 'sets correct url for custom AWS region' , ( ) => {
137+ upload = new Upload ( 'b' , { aws : { region : 'my-region-1' } } ) ;
141138 assert . equal ( upload . opts . url , 'https://s3-my-region-1.amazonaws.com/b/' ) ;
142139 } ) ;
143140
141+ it ( 'sets correct url for cn-north-1 AWS region' , ( ) => {
142+ upload = new Upload ( 'b' , { aws : { region : 'cn-north-1' } } ) ;
143+ assert . equal ( upload . opts . url , 'https://s3.cn-north-1.amazonaws.com/b/' ) ;
144+ } ) ;
145+
144146 it ( 'sets custom url' , ( ) => {
145147 upload = new Upload ( 'b' , {
146148 url : 'http://cdn.app.com/' ,
You can’t perform that action at this time.
0 commit comments