From b048aad579669699d52b837af74524c15ffee40b Mon Sep 17 00:00:00 2001 From: Enguerrand ARMINJON <37028599+EArminjon@users.noreply.github.com> Date: Tue, 14 Jan 2025 16:28:07 +0100 Subject: [PATCH] fix: improve ios bundleID regex to stop bundleIDs from throwing incorrectly (#357) Co-authored-by: russellwheatley --- .../flutterfire_cli/lib/src/common/utils.dart | 2 +- packages/flutterfire_cli/test/unit_test.dart | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/flutterfire_cli/lib/src/common/utils.dart b/packages/flutterfire_cli/lib/src/common/utils.dart index 2229b6e9..adf0e1de 100644 --- a/packages/flutterfire_cli/lib/src/common/utils.dart +++ b/packages/flutterfire_cli/lib/src/common/utils.dart @@ -511,7 +511,7 @@ void validateAppBundleId( String platform, ) { final bundleIdRegex = RegExp( - r'^[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?)+$', + r'^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?|([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?)+))$', ); if (!bundleIdRegex.hasMatch(bundleId)) { diff --git a/packages/flutterfire_cli/test/unit_test.dart b/packages/flutterfire_cli/test/unit_test.dart index 3d38382b..b8011825 100644 --- a/packages/flutterfire_cli/test/unit_test.dart +++ b/packages/flutterfire_cli/test/unit_test.dart @@ -42,6 +42,20 @@ void main() { ), returnsNormally, ); + expect( + () => validateAppBundleId( + 'example', + kIos, + ), + returnsNormally, + ); + expect( + () => validateAppBundleId( + 'exampleEN', + kIos, + ), + returnsNormally, + ); }); test('Invalid bundle IDs', () { @@ -73,13 +87,6 @@ void main() { ), throwsA(isA()), ); - expect( - () => validateAppBundleId( - 'example', - kIos, - ), - throwsA(isA()), - ); }); });