From 02a37adad0444a587c40dda2c67996fc48337d7a Mon Sep 17 00:00:00 2001 From: Stephen Date: Thu, 13 Sep 2018 11:26:57 -0400 Subject: [PATCH] fix: copy(): Use correct destination file name in URI (#389) --- src/file.ts | 2 +- test/file.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/file.ts b/src/file.ts index daa038dfc..7014244b5 100644 --- a/src/file.ts +++ b/src/file.ts @@ -530,7 +530,7 @@ class File extends ServiceObject { { method: 'POST', uri: `/rewriteTo/b/${destBucket.name}/o/${ - encodeURIComponent(destName)}`, + encodeURIComponent(newFile.name)}`, qs: query, json: options, headers, diff --git a/test/file.ts b/test/file.ts index 03f42780c..e4167bbbc 100644 --- a/test/file.ts +++ b/test/file.ts @@ -453,9 +453,10 @@ describe('File', () => { } it('should allow a string', done => { - const newFileName = 'new-file-name.png'; + const newFileName = '/new-file-name.png'; + const newFile = new File(BUCKET, newFileName); const expectedPath = - `/rewriteTo/b/${file.bucket.name}/o/${newFileName}`; + `/rewriteTo/b/${file.bucket.name}/o/${newFile.name}`; assertPathEquals(file, expectedPath, done); file.copy(newFileName); });