diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fd8eb066..90a95e9de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/storage?activeTab=versions +## [6.5.4](https://github.com/googleapis/nodejs-storage/compare/v6.5.3...v6.5.4) (2022-10-20) + + +### Bug Fixes + +* Revert STORAGE_EMULATOR_HOST handling ([#2089](https://github.com/googleapis/nodejs-storage/issues/2089)) ([48dce65](https://github.com/googleapis/nodejs-storage/commit/48dce654064470f7496d160d87b696ab5cfd65d4)) + ## [6.5.3](https://github.com/googleapis/nodejs-storage/compare/v6.5.2...v6.5.3) (2022-10-18) diff --git a/package.json b/package.json index 6e37f3bb6..4dce00d03 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/storage", "description": "Cloud Storage Client Library for Node.js", - "version": "6.5.3", + "version": "6.5.4", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 8fb17002f..9aa59e4af 100644 --- a/samples/package.json +++ b/samples/package.json @@ -17,7 +17,7 @@ }, "dependencies": { "@google-cloud/pubsub": "^3.0.0", - "@google-cloud/storage": "^6.5.3", + "@google-cloud/storage": "^6.5.4", "node-fetch": "^2.6.7", "uuid": "^8.0.0", "yargs": "^16.0.0" diff --git a/src/storage.ts b/src/storage.ts index d1a4b6945..cbd5bc275 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -664,12 +664,8 @@ export class Storage extends Service { options = Object.assign({}, options, {apiEndpoint}); - // Note: EMULATOR_HOST, if present and not overridden, has been applied to - // `options` at this point. Also, this uses string concatenation because the - // endpoint may contain a base path, and any trailing slash on that will - // have been removed, so using the two-arg URL constructor for relative path - // resolution won't work. - const baseUrl = new URL(options.apiEndpoint + '/storage/v1').href; + // Note: EMULATOR_HOST is an experimental configuration variable. Use apiEndpoint instead. + const baseUrl = EMULATOR_HOST || `${options.apiEndpoint}/storage/v1`; const config = { apiEndpoint: options.apiEndpoint!, diff --git a/test/index.ts b/test/index.ts index eb29893b8..166da822a 100644 --- a/test/index.ts +++ b/test/index.ts @@ -435,33 +435,27 @@ describe('Storage', () => { delete process.env.STORAGE_EMULATOR_HOST; }); - it('should set baseUrl to env var STORAGE_EMULATOR_HOST plus standard path', () => { + it('should set baseUrl to env var STORAGE_EMULATOR_HOST', () => { const storage = new Storage({ projectId: PROJECT_ID, }); const calledWith = storage.calledWith_[0]; - assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST + '/storage/v1'); + assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST); assert.strictEqual( calledWith.apiEndpoint, 'https://internal.benchmark.com/path' ); }); - it('should be overridden by apiEndpoint', () => { + it('should be overriden by apiEndpoint', () => { const storage = new Storage({ projectId: PROJECT_ID, apiEndpoint: 'https://some.api.com', }); const calledWith = storage.calledWith_[0]; - // NOTE: this used to assert partially the opposite of what the test - // says: it checked that baseUrl was _not_ overridden, but apiEndpoint - // was. - assert.strictEqual( - calledWith.baseUrl, - 'https://some.api.com/storage/v1' - ); + assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST); assert.strictEqual(calledWith.apiEndpoint, 'https://some.api.com'); }); @@ -474,13 +468,7 @@ describe('Storage', () => { }); const calledWith = storage.calledWith_[0]; - // NOTE: this used to assert partially the opposite of what the test - // says: it checked that baseUrl was _not_ overridden, but apiEndpoint - // was. - assert.strictEqual( - calledWith.baseUrl, - 'https://internal.benchmark.com/path/storage/v1' - ); + assert.strictEqual(calledWith.baseUrl, EMULATOR_HOST); assert.strictEqual( calledWith.apiEndpoint, 'https://internal.benchmark.com/path'