Skip to content

Commit c7518f7

Browse files
authored
Update to regex to look for underscore delimited labels (#12)
* Update to regex to look for underscore delimited labels * Allow for more than one delimiter in tool pattern
1 parent a53933c commit c7518f7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pkgs/dash_analytics/lib/src/config_handler.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ const String telemetryFlagPattern = r'^reporting=([0|1]) *$';
1919
/// from the configuration file
2020
///
2121
/// Example:
22-
/// flutter-tools=2022-10-26,1
22+
/// flutter_tools=2022-10-26,1
2323
const String toolPattern =
24-
r'^([A-Za-z0-9]+-*[A-Za-z0-9]*)=([0-9]{4}-[0-9]{2}-[0-9]{2}),([0-9]+)$';
24+
r'^([A-Za-z0-9]+[A-Za-z0-9_]*)=([0-9]{4}-[0-9]{2}-[0-9]{2}),([0-9]+)$';
2525

2626
class ConfigHandler {
2727
/// Regex pattern implementation for matching a line in the config file

pkgs/dash_analytics/test/dash_analytics_test.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void main() {
3030
late UserProperty userProperty;
3131

3232
const String homeDirName = 'home';
33-
const String initialToolName = 'initialTool';
33+
const String initialToolName = 'initial_tool';
3434
const String secondTool = 'newTool';
3535
const String measurementId = 'measurementId';
3636
const String apiSecret = 'apiSecret';
@@ -104,6 +104,10 @@ void main() {
104104
'There should only be 4 files in the $kDartToolDirectoryName directory');
105105
expect(analytics.shouldShowMessage, true,
106106
reason: 'For the first run, analytics should default to being enabled');
107+
expect(configFile.readAsLinesSync().length,
108+
kConfigString.split('\n').length + 1,
109+
reason: 'The number of lines should equal lines in constant value + 1 '
110+
'for the initialized tool');
107111
});
108112

109113
test('New tool is successfully added to config file', () {

0 commit comments

Comments
 (0)