Skip to content

Commit

Permalink
fix: improve ios bundleID regex to stop bundleIDs from throwing incor…
Browse files Browse the repository at this point in the history
…rectly (#357)

Co-authored-by: russellwheatley <[email protected]>
  • Loading branch information
EArminjon and russellwheatley authored Jan 14, 2025
1 parent 2a0f09a commit b048aad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/flutterfire_cli/lib/src/common/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
21 changes: 14 additions & 7 deletions packages/flutterfire_cli/test/unit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ void main() {
),
returnsNormally,
);
expect(
() => validateAppBundleId(
'example',
kIos,
),
returnsNormally,
);
expect(
() => validateAppBundleId(
'exampleEN',
kIos,
),
returnsNormally,
);
});

test('Invalid bundle IDs', () {
Expand Down Expand Up @@ -73,13 +87,6 @@ void main() {
),
throwsA(isA<ValidationException>()),
);
expect(
() => validateAppBundleId(
'example',
kIos,
),
throwsA(isA<ValidationException>()),
);
});
});

Expand Down

0 comments on commit b048aad

Please sign in to comment.