url2query static method

Map url2query(
  1. String url
)

Implementation

static Map url2query(String url) {
  var search = RegExp('([^&=]+)=?([^&]*)');
  var result = {};

  // Get rid off the beginning ? in query strings.
  if (url.startsWith('?')) url = url.substring(1);

  // A custom decoder.
  decode(String s) => Uri.decodeComponent(s.replaceAll('+', ' '));

  // Go through all the matches and build the result map.
  for (Match match in search.allMatches(url)) {
    result[decode(match.group(1)!)] = decode(match.group(2)!);
  }

  return result;
}