parseUsername static method
Parses a username from a url.
Implementation
static String? parseUsername(String nameOrUrl) {
if (nameOrUrl.isEmpty) {
return null;
}
if (validateUsername(nameOrUrl)) {
return nameOrUrl;
}
final regMatch = RegExp(r'youtube\..+?/user/(.*?)(?:\?|&|/|$)')
.firstMatch(nameOrUrl)
?.group(1);
if (!regMatch.isNullOrWhiteSpace && validateUsername(regMatch!)) {
return regMatch;
}
return null;
}