Skip to content
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

fix(storage, android): fix refFromUrl() when using firebase storage emulator. Essentially, check 10.0.2.2 domain as well. #12047

Merged

Conversation

ellet0
Copy link
Contributor

@ellet0 ellet0 commented Dec 16, 2023

Description

Fix bug when using firebase storage emulator on Android

Related Issues

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • [ x I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Suggestion

The current code

 if (decodedUrl.contains(_firebaseStorageHost) ||
      decodedUrl.contains('localhost')) {
    String origin;
    if (decodedUrl.contains('localhost')) {
      Uri uri = Uri.parse(url);
      origin = '^http?://${uri.host}:${uri.port}';
    } else {

check for the host by using the contains which might be not the most efficient, instead, it would be better to use the Uri class from dart

The fix I made didn't change this and follow the current code to not change too much

@russellwheatley russellwheatley changed the title Add 10.0.2.2 for firebase storage emulator fix(storage, android): fixrefFromUrl() when using firebase storage emulator on android. Jan 8, 2024
@russellwheatley russellwheatley changed the title fix(storage, android): fixrefFromUrl() when using firebase storage emulator on android. fix(storage, android): fix refFromUrl() when using firebase storage emulator on android. Jan 8, 2024
@russellwheatley russellwheatley changed the title fix(storage, android): fix refFromUrl() when using firebase storage emulator on android. fix(storage, android): fix refFromUrl() when using firebase storage emulator. Essentially, check 10.0.2.2 domain as well. Jan 8, 2024
@russellwheatley
Copy link
Member

@ellet0 - you need to format the files. Please see environment setup to install melos. Once installed, run melos run format to fix. Thanks!

The e2e tests failures are unrelated to this PR.

@ellet0
Copy link
Contributor Author

ellet0 commented Jan 8, 2024

@ellet0 - you need to format the files. Please see environment setup to install melos. Once installed, run melos run format to fix. Thanks!

The e2e tests failures are unrelated to this PR.

Sure, I will do that in a couple of hours

@ellet0
Copy link
Contributor Author

ellet0 commented Jan 8, 2024

@ellet0 - you need to format the files. Please see environment setup to install melos. Once installed, run melos run format to fix. Thanks!

The e2e tests failures are unrelated to this PR.

Done

@Lyokone Lyokone merged commit cef006a into firebase:master Jan 9, 2024
18 checks passed
@firebase firebase locked and limited conversation to collaborators Feb 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [firebase_storage] refFromURL doesn't work on android when using firebase emulator
4 participants