parseFileContents static method

Map<String, String> parseFileContents(
  1. String response
)

Parses <file_content path="...">...</file_content> blocks from response.

Visible for testing.

Implementation

static Map<String, String> parseFileContents(String response) {
  final regex = RegExp(
    r'<file_content path="(.*?)">(.*?)</file_content>',
    dotAll: true,
  );
  final out = <String, String>{};
  for (final match in regex.allMatches(response)) {
    out[match.group(1)!] = match.group(2)!.trim();
  }
  return out;
}