Skip to content

Commit

Permalink
fix: copy(): Use correct destination file name in URI (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus authored and JustinBeckwith committed Sep 13, 2018
1 parent 6d05e94 commit 02a37ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions test/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 02a37ad

Please sign in to comment.