nodejs-storage icon indicating copy to clipboard operation
nodejs-storage copied to clipboard

File.publicUrl() unexpectedly escapes forward slashes in > 7.6.0

Open Jeanno opened this issue 1 year ago • 11 comments

Summary

Forward slashes are escaped to "%2F" in File.publicUrl() for files that are > 1 level deep.

Unexpected result: "https://storage.googleapis.com/bucketId/path%2Fto%2Ffile" Expected result: "https://storage.googleapis.com/bucketId/path/to/file"

The expected result is given before <= 6.5.4. So this issue looks like a regression.

Environment details

  • @google-cloud/storage version: > 7.6.0

Steps to reproduce

  1. Run the example code. This can also be reproduced in npm's runkit. (https://npm.runkit.com/%40google-cloud%2Fstorage)
var Storage = require("@google-cloud/storage")

var storage = new Storage.Storage();
var bucket = storage.bucket('bucketId');
var file = bucket.file('path/to/file');
var url = file.publicUrl();

Unexpected result: "https://storage.googleapis.com/bucketId/path%2Fto%2Ffile" Expected result: "https://storage.googleapis.com/bucketId/path/to/file"

Additional info

There was an identical bug in the python library. https://github.com/googleapis/google-cloud-python/issues/3809

Jeanno avatar Mar 03 '24 21:03 Jeanno