diff --git a/CHANGELOG.md b/CHANGELOG.md index 920e2a56d..e500c6ee0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/storage?activeTab=versions +## [7.10.2](https://github.com/googleapis/nodejs-storage/compare/v7.10.1...v7.10.2) (2024-04-26) + + +### Bug Fixes + +* Use correct indices for file.from and fix tests to verify names ([#2449](https://github.com/googleapis/nodejs-storage/issues/2449)) ([d4240fa](https://github.com/googleapis/nodejs-storage/commit/d4240fa5c8c0353de81cc8c052eea2915c3e383c)) + ## [7.10.1](https://github.com/googleapis/nodejs-storage/compare/v7.10.0...v7.10.1) (2024-04-22) diff --git a/package.json b/package.json index fd23f6f93..17c3edb72 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/storage", "description": "Cloud Storage Client Library for Node.js", - "version": "7.10.1", + "version": "7.10.2", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index edf1724aa..2518ca5a6 100644 --- a/samples/package.json +++ b/samples/package.json @@ -17,7 +17,7 @@ }, "dependencies": { "@google-cloud/pubsub": "^4.0.0", - "@google-cloud/storage": "^7.10.1", + "@google-cloud/storage": "^7.10.2", "node-fetch": "^2.6.7", "uuid": "^8.0.0", "yargs": "^16.0.0" diff --git a/src/file.ts b/src/file.ts index e4438a7d8..14024cb2b 100644 --- a/src/file.ts +++ b/src/file.ts @@ -2410,11 +2410,11 @@ class File extends ServiceObject { const httpsMatches = [...publicUrlOrGsUrl.matchAll(HTTPS_PUBLIC_URL_REGEX)]; if (gsMatches.length > 0) { - const bucket = new Bucket(storageInstance, gsMatches[0][1]); - return new File(bucket, gsMatches[0][2], options); + const bucket = new Bucket(storageInstance, gsMatches[0][2]); + return new File(bucket, gsMatches[0][3], options); } else if (httpsMatches.length > 0) { - const bucket = new Bucket(storageInstance, httpsMatches[0][2]); - return new File(bucket, httpsMatches[0][3], options); + const bucket = new Bucket(storageInstance, httpsMatches[0][3]); + return new File(bucket, httpsMatches[0][4], options); } else { throw new Error( 'URL string must be of format gs://bucket/file or https://storage.googleapis.com/bucket/file' diff --git a/test/file.ts b/test/file.ts index bd95ad26d..bd60273f4 100644 --- a/test/file.ts +++ b/test/file.ts @@ -5180,8 +5180,8 @@ describe('File', () => { const result = File.from(gsUrl, STORAGE); assert(result); - assert(result.bucket.name, 'mybucket'); - assert(result.name, 'myfile'); + assert.strictEqual(result.bucket.name, 'mybucket'); + assert.strictEqual(result.name, 'myfile'); }); it('should create a File object from a gs:// formatted URL including a folder', () => { @@ -5189,8 +5189,8 @@ describe('File', () => { const result = File.from(gsUrl, STORAGE); assert(result); - assert(result.bucket.name, 'mybucket'); - assert(result.name, 'myfolder/myfile'); + assert.strictEqual(result.bucket.name, 'mybucket'); + assert.strictEqual(result.name, 'myfolder/myfile'); }); it('should create a File object from a https:// formatted URL', () => { @@ -5198,8 +5198,8 @@ describe('File', () => { const result = File.from(httpsUrl, STORAGE); assert(result); - assert(result.bucket.name, 'mybucket'); - assert(result.name, 'myfile'); + assert.strictEqual(result.bucket.name, 'mybucket'); + assert.strictEqual(result.name, 'myfile'); }); it('should create a File object from a https:// formatted URL including a folder', () => { @@ -5208,8 +5208,8 @@ describe('File', () => { const result = File.from(httpsUrl, STORAGE); assert(result); - assert(result.bucket.name, 'mybucket'); - assert(result.name, 'myfolder/myfile'); + assert.strictEqual(result.bucket.name, 'mybucket'); + assert.strictEqual(result.name, 'myfolder/myfile'); }); it('should throw an error when invoked with an incorrectly formatted URL', () => {