decodeUri method

String decodeUri(
  1. DecodeMode mode
)

Implementation

String decodeUri(DecodeMode mode) {
  var codes = codeUnits;
  var changed = false;
  var pos = 0;
  while (pos < codes.length) {
    final char = codes[pos];
    if (char == _PERCENT) {
      if (pos + 2 >= length) break;
      final hex1 = _decodeHex(codes[pos + 1]);
      final hex2 = _decodeHex(codes[pos + 2]);
      final codeUnit = _getCodeUnit(hex1, hex2);
      if (_decode(codeUnit, mode)) {
        if (!changed) {
          // make a copy
          codes = codes.toList();
          changed = true;
        }
        codes[pos] = codeUnit!;
        codes.removeRange(pos + 1, pos + 3);
      }
    }
    pos++;
  }
  return changed ? String.fromCharCodes(codes) : this;
}