File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -372,12 +372,14 @@ export class Storage extends Service {
372372 * @param {StorageOptions } [options] Configuration options.
373373 */
374374 constructor ( options : StorageOptions = { } ) {
375- options . apiEndpoint = options . apiEndpoint || 'storage.googleapis.com' ;
375+ options = Object . assign ( { } , options , {
376+ apiEndpoint : options . apiEndpoint || 'storage.googleapis.com' ,
377+ } ) ;
376378 const url =
377379 process . env . STORAGE_EMULATOR_HOST ||
378380 `https://${ options . apiEndpoint } /storage/v1` ;
379381 const config = {
380- apiEndpoint : options . apiEndpoint ,
382+ apiEndpoint : options . apiEndpoint ! ,
381383 baseUrl : url ,
382384 projectIdRequired : false ,
383385 scopes : [
Original file line number Diff line number Diff line change @@ -141,6 +141,20 @@ describe('Storage', () => {
141141 ) ;
142142 } ) ;
143143
144+ it ( 'should not modify options argument' , ( ) => {
145+ const options = {
146+ projectId : PROJECT_ID ,
147+ } ;
148+ const expectedCalledWith = Object . assign ( { } , options , {
149+ apiEndpoint : 'storage.googleapis.com' ,
150+ } ) ;
151+ storage = new Storage ( options ) ;
152+ const calledWith = storage . calledWith_ [ 1 ] ;
153+ assert . notStrictEqual ( calledWith , options ) ;
154+ assert . notDeepStrictEqual ( calledWith , options ) ;
155+ assert . deepStrictEqual ( calledWith , expectedCalledWith ) ;
156+ } ) ;
157+
144158 it ( 'should propagate the apiEndpoint option' , ( ) => {
145159 const apiEndpoint = 'some.fake.endpoint' ;
146160 storage = new Storage ( {
You can’t perform that action at this time.
0 commit comments