parseLinkHeader function Null safety

Map<String, String> parseLinkHeader(
  1. String input
)

Implementation

Map<String, String> parseLinkHeader(String input) {
  final out = <String, String>{};
  final parts = input.split(', ');
  for (final part in parts) {
    if (part[0] != '<') {
      throw const FormatException('Invalid Link Header');
    }
    final kv = part.split('; ');
    var url = kv[0].substring(1);
    url = url.substring(0, url.length - 1);
    var key = kv[1];
    key = key.replaceAll('"', '').substring(4);
    out[key] = url;
  }
  return out;
}