Skip to content

Commit d969955

Browse files
committed
fix-regexp
1 parent f8f8bad commit d969955

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tool/task.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ Not all files are formatted:
937937
Future<void> validateSdkDocs() async {
938938
await docSdk();
939939
const expectedLibCount = 0;
940-
const expectedSubLibCount = 13;
940+
const expectedSubLibCount = 20;
941941
const expectedTotalCount = 20;
942942
var indexHtml = File(path.join(_sdkDocsDir.path, 'index.html'));
943943
if (!indexHtml.existsSync()) {
@@ -953,8 +953,9 @@ Future<void> validateSdkDocs() async {
953953
}
954954
print("Found $foundLibCount 'dart:' entries in 'index.html'");
955955

956-
var foundSubLibCount =
957-
_findCount(indexContents, '<li class="section-subitem"><a href="dart-');
956+
var libLinkPattern =
957+
RegExp('<li class="section-subitem"><a [^>]*href="dart-');
958+
var foundSubLibCount = _findCount(indexContents, libLinkPattern);
958959
if (expectedSubLibCount != foundSubLibCount) {
959960
throw StateError("Expected $expectedSubLibCount 'dart:' entries in "
960961
"'index.html' to be in categories, but found $foundSubLibCount");
@@ -987,12 +988,12 @@ final Directory _sdkDocsDir =
987988
Directory.systemTemp.createTempSync('sdkdocs').absolute;
988989

989990
/// Returns the number of (perhaps overlapping) occurrences of [str] in [match].
990-
int _findCount(String str, String match) {
991+
int _findCount(String str, Pattern match) {
991992
var count = 0;
992993
var index = str.indexOf(match);
993994
while (index != -1) {
994995
count++;
995-
index = str.indexOf(match, index + match.length);
996+
index = str.indexOf(match, index + 1);
996997
}
997998
return count;
998999
}

0 commit comments

Comments
 (0)