parse static method
Implementation
static MediumPostUrl? parse(String url) {
var matches = RegExp(
r'^(?:https?:)?\/\/medium\.com\/(?:(?:@(?<username>[A-z0-9]+))|(?<publication>[a-z-]+))\/(?<slug>[a-z0-9\-]+)-(?<post_id>[A-z0-9]+)(?:\?.*)?$')
.allMatches(url);
var postId = matches.getValue("post_id");
if (postId == null) {
matches = RegExp(
r'^(?:https?:)?\/\/(?<publication>(?!www)[a-z-]+)\.medium\.com\/(?<slug>[a-z0-9\-]+)-(?<post_id>[A-z0-9]+)(?:\?.*)?$')
.allMatches(url);
postId = matches.getValue("post_id");
}
if (postId == null) return null;
var slug = matches.getValue("slug");
var userName = matches.getValue("username");
var publication = matches.getValue("publication");
return MediumPostUrl._(userName, publication, postId, slug);
}