Skip to content

Commit

Permalink
fix(storage): update regex for cloudStoragePath
Browse files Browse the repository at this point in the history
  • Loading branch information
SelaseKay committed Dec 9, 2024
1 parent 165d2ab commit b8b632f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const String _cloudStorageHost =
const String _bucketDomain = r'([A-Za-z0-9.\-_]+)';
const String _version = 'v[A-Za-z0-9_]+';
const String _firebaseStoragePath = r'(/([^?#]*).*)?$';
const String _cloudStoragePath = r'([^?#]*)*$';
const String _cloudStoragePath = '([^?#]*)';
const String _optionalPort = r'(?::\d+)?';

/// Returns a path from a given `http://` or `https://` URL.
Expand Down
10 changes: 10 additions & 0 deletions packages/firebase_storage/firebase_storage/test/utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ void main() {
expect(result?['path'], 'foo+bar/file with spaces .png');
});

test('parses a https url with query param', () {
String url =
'https://storage.cloud.google.com/valid-url.appspot.com/path/to/foo_bar.jpg?foo=bar';

final result = partsFromHttpUrl(url);

expect(result?['bucket'], 'valid-url.appspot.com');
expect(result?['path'], 'path/to/foo_bar.jpg');
});

// TODO(helenaford): regexp can't handle no paths
// test('sets path to default if null', () {
// String url =
Expand Down

0 comments on commit b8b632f

Please sign in to comment.