parseDeeplinkConfig method
Parse a deep link configuration Dart file content.
@param content Raw content of lib/config/deeplink.dart. @return A map with extracted configuration values.
Implementation
Map<String, dynamic> parseDeeplinkConfig(String content) {
final config = <String, dynamic>{};
final teamIdMatch = RegExp(r"'team_id':\s*'([^']+)'").firstMatch(content);
if (teamIdMatch != null) {
config['teamId'] = teamIdMatch.group(1);
}
final bundleIdMatch = RegExp(
r"'bundle_id':\s*'([^']+)'",
).firstMatch(content);
if (bundleIdMatch != null) {
config['bundleId'] = bundleIdMatch.group(1);
}
final packageNameMatch = RegExp(
r"'package_name':\s*'([^']+)'",
).firstMatch(content);
if (packageNameMatch != null) {
config['packageName'] = packageNameMatch.group(1);
}
final fingerprintsMatch = RegExp(
r"'sha256_fingerprints':\s*\[(.*?)\]",
dotAll: true,
).firstMatch(content);
if (fingerprintsMatch != null) {
final fingerprintsContent = fingerprintsMatch.group(1) ?? '';
final fingerprintMatches = RegExp(
r"'([^']+)'",
).allMatches(fingerprintsContent);
config['fingerprints'] =
fingerprintMatches.map((m) => m.group(1)!).toList();
}
final pathsMatch = RegExp(
r"'paths':\s*\[(.*?)\]",
dotAll: true,
).firstMatch(content);
if (pathsMatch != null) {
final pathsContent = pathsMatch.group(1) ?? '';
final pathMatches = RegExp(r"'([^']+)'").allMatches(pathsContent);
config['paths'] = pathMatches.map((m) => m.group(1)!).toList();
}
return config;
}