Skip to content

Support storage.googleapis.com in refFromUrl #2758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 27, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Mar 17, 2020

This modifies refFromUrl to accept URLs generated by Cloud Storage.

Tested that this supports URLs from the Cloud Console as well as the format specified here:

https://cloud.google.com/storage/docs/access-control/signed-urls

Fixes #2625

});
it('Works with storage.cloud.google.com URLs', () => {
const ref = service.refFromURL(
`https://storage.cloud.google.com/mybucket/path%20with%20space/image.png`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOC, will this generate the same result?
https://storage.cloud.google.com/mybucket/path%20with%20space%2Fimage.png

Maybe add a test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test.

const httpRegex = new RegExp(
`^https?://${hostRegex}/${version}/b/${bucketDomain}/o${path}`,
const firebaseStorageHost = DEFAULT_HOST.replace(/[.]/g, '\\.');
const firebaseStoragePath = '(/([^?#]*).*)?$';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's special about #? Trying to understand the difference between firebaseStoragePath and cloudStoragePath.

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian Mar 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably exclude # in both cases, even though I don't see GCS creating URLs that provide anchors. I updated the cloudStoragePath.

I am not sure why we are using an extra .* in firebaseStoragePath, but I'd rather leave it the way it was as I can see neither harm nor benefit.

@fredzqm fredzqm assigned schmidt-sebastian and unassigned fredzqm Mar 23, 2020
@schmidt-sebastian
Copy link
Contributor Author

@Feiyang1 for approval. Thanks.

@google-oss-bot
Copy link
Contributor

Binary Size Report

Affected SDKs

SDKTypeBase (a85f81d)Head (669d900)Diff
@firebase/loggermodule?4778.00? (?)
esm2017?3223.00? (?)
main?5087.00? (?)
@firebase/storagemodule?62706.00? (?)
esm2017?56574.00? (?)
main?62912.00? (?)
@firebase/utilmodule?18551.00? (?)
browser?19454.00? (?)
esm2017?17369.00? (?)
main?19481.00? (?)
@firebase/appreact-native?9862.00? (?)
lite-esm2017?7748.00? (?)
module?11011.00? (?)
browser?11108.00? (?)
esm2017?9461.00? (?)
main?10105.00? (?)
lite?9102.00? (?)
@firebase/firestoremodule?269748.00? (?)
browser?272957.00? (?)
esm2017?269748.00? (?)
main?490305.00? (?)
@firebase/installationsmodule?21544.00? (?)
esm2017?16530.00? (?)
main?21995.00? (?)
@firebase/functionsmodule?8994.00? (?)
browser?9174.00? (?)
esm2017?7010.00? (?)
main?9209.00? (?)
@firebase/webchannel-wrappermodule?41226.00? (?)
main?40383.00? (?)
@firebase/performancemodule?24914.00? (?)
browser?25158.00? (?)
esm2017?23188.00? (?)
main?25158.00? (?)
firebasefirebase-installations.js?19436.00? (?)
firebase-storage.js?41411.00? (?)
firebase-messaging.js?39431.00? (?)
firebase.js?847343.00? (?)
firebase-auth.js?175057.00? (?)
firebase-analytics.js?26780.00? (?)
firebase-performance-standalone.js?46946.00? (?)
firebase-remote-config.js?37217.00? (?)
firebase-performance.js?37211.00? (?)
firebase-app.js?20008.00? (?)
firebase-firestore.js?313937.00? (?)
firebase-database.js?185548.00? (?)
firebase-performance-standalone.es2017.js?70398.00? (?)
firebase-functions.js?9642.00? (?)
@firebase/analyticsmodule?9371.00? (?)
esm2017?8682.00? (?)
main?9689.00? (?)
@firebase/authmodule?177089.00? (?)
main?177099.00? (?)
@firebase/remote-configmodule?22720.00? (?)
browser?23103.00? (?)
esm2017?17705.00? (?)
main?23103.00? (?)
@firebase/testingmain?6598.00? (?)
@firebase/messagingmodule?30549.00? (?)
esm2017?22806.00? (?)
main?31006.00? (?)
@firebase/databasemodule?264057.00? (?)
browser?265575.00? (?)
esm2017?232641.00? (?)
main?266339.00? (?)
@firebase/componentmodule?5046.00? (?)
browser?5164.00? (?)
esm2017?3898.00? (?)
main?5164.00? (?)
@firebase/polyfillmodule?666.00? (?)
main?733.00? (?)
Metric Unit: byte

Test Logs

@schmidt-sebastian schmidt-sebastian merged commit e7b230c into master Mar 27, 2020
@firebase firebase locked and limited conversation to collaborators Apr 26, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/storageapis branch November 9, 2020 22:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

storage.refFromURL() is not working correctly
4 participants