isEncoded static method
Checks if a string appears to be already URL encoded
Implementation
static bool isEncoded(String string) {
if (string.isEmpty) return false;
// Check for typical URL encoding patterns like %20, %3A, etc.
final hasEncodedChars =
RegExp(r'%[0-9A-F]{2}', caseSensitive: false).hasMatch(string);
// Match iOS behavior - ignore double encoding check for now
return hasEncodedChars;
// TODO: Decide what to do with double encoding
// Check if double encoding has occurred (e.g., %253A instead of %3A)
// final hasDoubleEncoding =
// RegExp(r'%25[0-9A-F]{2}', caseSensitive: false).hasMatch(string);
//
// If we have encoded chars but no double encoding, it's likely properly encoded
// return hasEncodedChars && !hasDoubleEncoding;
}