Skip to content

Signing file with leading slash using getSignedUrl results in double slash  #947

@emielvanliere

Description

@emielvanliere

Environment details

  • OS: MacOS
  • Node.js version:10.15.0
  • npm version:6.13.0
  • @google-cloud/storage version: 4.1.2 (as part of firebase-admin-node 8.8.0)

Steps to reproduce

After upgrading to firebase-admin-node 8.8.0, which updates @google-cloud/storage version to 4.1.2 I'm experiencing an issue signing files/paths that start with a slash.

Reproduce:

const bucketName = "my_bucket";
const file = "/file.jpg";
const bucket = firebase.storage().bucket(bucketName);
const getSignedUrls = await bucket.file(file).getSignedUrl({action:"read"});
const signedUrl = getSignedUrls[0];

signedUrl will now be https://storage.googleapis.com/my_bucket//file.jpg?<signature> instead of https://storage.googleapis.com/my_bucket/file.jpg?<signature>. Notice the dobule slash in the first url; files with a double slash in the url are not accessible on cloud storage.

I would expect files that start with a slash to reference the root of the bucket (as an absolute path), and I would not expect the library to insert an extra slash.

This is probably related to the change in: #820

Metadata

Metadata

Labels

api: storageIssues related to the googleapis/nodejs-storage API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions