Skip to content

Commit

Permalink
use Equals instead of ToLower
Browse files Browse the repository at this point in the history
  • Loading branch information
MIRIMIRIM committed Aug 13, 2024
1 parent 8dd5584 commit 4da9c30
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion OKP.Core/Interface/Acgnx/AcgnxAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public AcgnxAdapter(TorrentContent torrent, Template template, string siteType)
httpClient.DefaultRequestHeaders.Add("user-agent", HttpHelper.GlobalUserAgent);
this.template = template;
this.torrent = torrent;
var cookieToken = HttpHelper.GlobalCookieContainer.GetCookies(httpClient.BaseAddress).ToList().Find(p => p.Name.ToLower() == "token");
var cookieToken = HttpHelper.GlobalCookieContainer.GetCookies(httpClient.BaseAddress).ToList().Find(p => p.Name.AsSpan().Equals("token", StringComparison.OrdinalIgnoreCase));
if (cookieToken is null)
{
Log.Error("Cannot find token of {Site}", site);
Expand Down
2 changes: 1 addition & 1 deletion OKP.Core/Interface/Acgrip/AcgripAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private bool Valid()
}
foreach (var tracker in trackers)
{
if (!torrent.Data.TorrentObject.Trackers.ToList().SelectMany(p => p).ToList().Exists(p => p.TrimEnd('/').ToLower() == tracker.TrimEnd('/').ToLower()))
if (!torrent.Data.TorrentObject.Trackers.SelectMany(p => p).Any(p => p.TrimEnd('/').Equals(tracker.TrimEnd('/'), StringComparison.OrdinalIgnoreCase)))
{
Log.Error("缺少Tracker:{0}", tracker);
return false;
Expand Down
2 changes: 1 addition & 1 deletion OKP.Core/Interface/Bangumi/BangumiAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override async Task<HttpResult> PingAsync()
}
else
{
foreach (var team in teamList.Where(team => team.name.ToLower() == template.Name.ToLower()))
foreach (var team in teamList.Where(team => team.name.Equals(template.Name, StringComparison.OrdinalIgnoreCase)))
{
teamID = team._id;
tagID = team.tag_id;
Expand Down
2 changes: 1 addition & 1 deletion OKP.Core/Interface/Nyaa/NyaaAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private bool Valid()
}
foreach (var tracker in trackers)
{
if (!torrent.Data.TorrentObject.Trackers.ToList().SelectMany(p => p).ToList().Exists(p => p.TrimEnd('/').ToLower() == tracker.TrimEnd('/').ToLower()))
if (!torrent.Data.TorrentObject.Trackers.SelectMany(p => p).Any(p => p.TrimEnd('/').Equals(tracker.TrimEnd('/'), StringComparison.OrdinalIgnoreCase)))
{
Log.Error("缺少Tracker:{0}", tracker);
return false;
Expand Down
6 changes: 3 additions & 3 deletions OKP.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ public static void Main(string[] args)
Log.Error("文件{File}不存在", file);
continue;
}
var extension = (Path.GetExtension(file) ?? "").ToLower();
var extension = (Path.GetExtension(file) ?? "").AsSpan();

if (extension == ".torrent")
if (extension.Equals(".torrent", StringComparison.OrdinalIgnoreCase))
{
Log.Information("正在发布 {File}", file);
SinglePublish(file, o.SettingFile, o.Cookies,o.AllowSkip);
continue;
}
if (extension == ".txt")
if (extension.Equals(".torrent", StringComparison.OrdinalIgnoreCase))
{
if (o.Cookies is null)
{
Expand Down

0 comments on commit 4da9c30

Please sign in to comment.