1
0
mirror of https://github.com/rudollee/HTMLParser.git synced 2025-07-17 23:15:39 +00:00

Null Case

This commit is contained in:
wook 2017-05-10 14:30:34 +09:00
parent 5f8b2bba41
commit 0396443a51
2 changed files with 4 additions and 4 deletions
HTMLParser.Example
HTMLParser

@ -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);
}
}
}