Fix Reference.fullPath to return the bucket-relative slash-path - #46
Merged
Merged
Conversation
`MockReference.fullPath` returned `gs://{bucket}{path}` (e.g.
`gs://some-bucketimages/photo.png`), but real Firebase Storage's
`Reference.fullPath` returns the bucket-relative slash-path with no
`gs://{bucket}` prefix and no leading slash (e.g. `images/photo.png`).
This bit a downstream test that synthesises `gs://{bucket}/{fullPath}`
URIs: under the mock it produced a doubled `gs://some-bucket/gs://some-bucket...`
prefix that doesn't occur against real Storage.
Fix `fullPath` to strip the `gs://{bucket}` prefix and the leading
slash, and update the existing `fullPath` expectations plus add tests
pinning the slash-path contract for top-level and nested references.
atn832
reviewed
Jun 5, 2026
| // (e.g. `images/someimage.png`), NOT a `gs://{bucket}` URI. The leading | ||
| // slash is also stripped to match real `Reference.fullPath`, where the | ||
| // root reference's `fullPath` is the empty string. See | ||
| // https://firebase.google.com/docs/reference/js/storage.reference.md#referencefullpath |
Owner
There was a problem hiding this comment.
This url returns error 404. It seems to have moved to https://firebase.google.com/docs/reference/js/storage.storagereference.md#storagereferencefullpath. I can fix it after I merge your PR
atn832
approved these changes
Jun 5, 2026
Owner
|
Thank you for your fix @nickmeinhold! I just published it at https://pub.dev/packages/firebase_storage_mocks/changelog#081. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
MockReference.fullPathreturns ags://{bucket}{path}URI:But real Firebase Storage's
Reference.fullPathreturns the bucket-relative slash-path — nogs://{bucket}prefix and no leading slash. For example,storage.ref().child('images/photo.png').fullPathisimages/photo.png, notgs://some-bucket/images/photo.png.Because the path is concatenated without a separator, a nested ref like
storage.ref('/images').child('/photo.png')even producedgs://some-bucketimages/photo.pngunder the mock.This bites downstream code that synthesises its own
gs://{bucket}/{fullPath}URIs from a reference: under the mock it yields a doubledgs://some-bucket/gs://some-bucket...prefix that never occurs against real Storage, forcing tests to encode the quirk.Fix
fullPathnow strips thegs://{bucket}prefix and the leading slash, returning the bucket-relative slash-path that matches real Firebase.fullPathexpectations (gs://some-bucket/someimage.png→someimage.png).gs://prefix.All tests pass (
flutter test→ 19 passing).