OLD | NEW |
---|---|
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:args/args.dart'; | 9 import 'package:args/args.dart'; |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 if (argResults['cache'] != null) { | 101 if (argResults['cache'] != null) { |
102 cache.base = Uri.base.resolve('${argResults['cache']}/'); | 102 cache.base = Uri.base.resolve('${argResults['cache']}/'); |
103 } | 103 } |
104 if (argResults['no-cache']) { | 104 if (argResults['no-cache']) { |
105 cache.base = null; | 105 cache.base = null; |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 /// Strips un-wanted characters from string [category] from CBE json. | 109 /// Strips un-wanted characters from string [category] from CBE json. |
110 String sanitizeCategory(String category) { | 110 String sanitizeCategory(String category) { |
111 // Category name starts with either two or three numbers and | 111 // Category name starts with a channel number (normally consisting of 1-3 |
Bill Hesse
2017/09/01 11:10:57
LGTM, but could you just regexp match $[0-9]+(.*)\
mkroghj
2017/09/01 11:37:34
swapped $ and ^.
Done
| |
112 // end with |all. Instead of doing any fancy regular-expr, | 112 // digits) and ends with |all. Instead of doing any fancy regular-expr, |
113 // we just test if third char is a number. | 113 // we just test if the char is not an alpha-char. |
114 return category.substring( | 114 int firstIndex = 0; |
115 category.codeUnitAt(2) <= 64 ? 3 : 2, category.length - 4); | 115 while ( |
116 category.codeUnitAt(firstIndex) <= 64 && firstIndex < category.length) { | |
117 firstIndex++; | |
118 } | |
119 return category.substring(firstIndex, category.length - 4); | |
116 } | 120 } |
OLD | NEW |