mirror of
https://github.com/rudollee/HTMLParser.git
synced 2025-07-17 23:15:39 +00:00
Null Case
This commit is contained in:
parent
5f8b2bba41
commit
0396443a51
@ -21,8 +21,8 @@ namespace HTMLParser.Example
|
||||
ParserEx parse = new ParserEx();
|
||||
|
||||
this.ParsedUrl.InnerHtml = parse.ParseUrl(this.txtSource.Value);
|
||||
this.parsedYoutube.InnerHtml = parse.GenerateYoutubeScripts(this.txtSource.Value).First();
|
||||
this.parsedUrlAndYoutube.InnerHtml = parse.GenerateYoutubeScripts(this.txtSource.Value).First() + parse.ParseUrl(this.txtSource.Value);
|
||||
this.parsedYoutube.InnerHtml = parse.GenerateYoutubeScripts(this.txtSource.Value).FirstOrDefault() ?? "";
|
||||
this.parsedUrlAndYoutube.InnerHtml = parse.ParseUrlAndYoutube(this.txtSource.Value);
|
||||
}
|
||||
}
|
||||
}
|
@ -59,7 +59,7 @@ namespace HTMLParser
|
||||
|
||||
public List<string> GenerateYoutubeScripts(string article)
|
||||
{
|
||||
if (string.IsNullOrEmpty(article)) return null;
|
||||
if (string.IsNullOrEmpty(article)) return new List<string>(new string[] { "" });
|
||||
|
||||
Regex regex = new Regex(@"youtu(?:\.be|be\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)");
|
||||
Match match = regex.Match(article);
|
||||
@ -75,7 +75,7 @@ namespace HTMLParser
|
||||
|
||||
public string ParseUrlAndYoutube(string article)
|
||||
{
|
||||
return this.GenerateYoutubeScripts(article).First() + this.ParseUrl(article);
|
||||
return this.GenerateYoutubeScripts(article).FirstOrDefault() ?? "" + this.ParseUrl(article);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user