Skip to content

Commit

Permalink
fix(storage, android): fix refFromUrl() when using firebase storage…
Browse files Browse the repository at this point in the history
… emulator. Essentially, check `10.0.2.2` domain as well. (#12047)

* Add 10.0.2.2 for firebase storage emulator

* Format utils.dart of firebase_storage
  • Loading branch information
ellet0 committed Jan 9, 2024
1 parent c6341b9 commit cef006a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/firebase_storage/firebase_storage/lib/src/utils.dart
Expand Up @@ -42,10 +42,12 @@ Map<String, String?>? partsFromHttpUrl(String url) {
}

// firebase storage url
// 10.0.2.2 is for Android when using firebase emulator
if (decodedUrl.contains(_firebaseStorageHost) ||
decodedUrl.contains('localhost')) {
decodedUrl.contains('localhost') ||
decodedUrl.contains('10.0.2.2')) {
String origin;
if (decodedUrl.contains('localhost')) {
if (decodedUrl.contains('localhost') || decodedUrl.contains('10.0.2.2')) {
Uri uri = Uri.parse(url);
origin = '^http?://${uri.host}:${uri.port}';
} else {
Expand Down

0 comments on commit cef006a

Please sign in to comment.