test(core/browser/platform): 26 extreme RED/GREEN TDD cycles and full regression hardening (3,235 PASS)
This commit is contained in:
parent
bcd242691f
commit
8677853822
100 changed files with 4814 additions and 333 deletions
|
|
@ -17,11 +17,37 @@ public static class SocialSiteDetector
|
|||
private static readonly Regex TikTokPathRe = new(@"/@[^/]+/video/([0-9]+)", RegexOptions.Compiled);
|
||||
private static readonly Regex FbPathRe = new(@"/(?:reel|videos)/([^/?#]+)", RegexOptions.Compiled);
|
||||
|
||||
/// <summary>문자열 URL이 소셜 영상 URL이면 정규화된 URL과 사이트 라벨을 반환.</summary>
|
||||
public static bool TryMatch(string? urlString, out string normalized, out string label)
|
||||
{
|
||||
normalized = "";
|
||||
label = "";
|
||||
if (string.IsNullOrWhiteSpace(urlString)) return false;
|
||||
urlString = urlString.Trim();
|
||||
if (urlString.Contains('\0')) return false;
|
||||
|
||||
if (urlString.StartsWith("javascript:", StringComparison.OrdinalIgnoreCase) ||
|
||||
urlString.StartsWith("data:", StringComparison.OrdinalIgnoreCase) ||
|
||||
urlString.StartsWith("file:", StringComparison.OrdinalIgnoreCase) ||
|
||||
urlString.StartsWith("blob:", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Uri.TryCreate(urlString, UriKind.Absolute, out var uri))
|
||||
return false;
|
||||
|
||||
return TryMatch(uri, out normalized, out label);
|
||||
}
|
||||
|
||||
/// <summary>소셜 영상 URL 이면 정규화된 URL 과 사이트 라벨을 반환.</summary>
|
||||
public static bool TryMatch(Uri url, out string normalized, out string label)
|
||||
{
|
||||
normalized = "";
|
||||
label = "";
|
||||
if (url == null || !url.IsAbsoluteUri) return false;
|
||||
if (url.Scheme != "http" && url.Scheme != "https") return false;
|
||||
|
||||
var host = (url.Host ?? "").ToLowerInvariant();
|
||||
var path = url.AbsolutePath ?? "";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue