Skip to content

Commit

Permalink
Merge pull request #1 from wordpure/main
Browse files Browse the repository at this point in the history
chore: optimize WeChat full path validation
  • Loading branch information
ZGGSONG authored Nov 9, 2024
2 parents 62715e8 + 34f2526 commit 043136a
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/WeChatOcr/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public partial class Utilities
{
path ??= WeChatDefaultPath;

// 判断是否为带有版本号的完整目录
if (WeChatVersionRegex().IsMatch(path))
// 根据给定路径下 mmmojo.dll 的存在与否,判断是否为微信完整路径
if (File.Exists(Path.Combine(path, MmMojoDll)))
return path.TrimEnd('\\');

// 从注册表中获取微信安装版本并根据参数path拼接微信安装目录
Expand All @@ -52,13 +52,6 @@ public partial class Utilities
return default;
}

/// <summary>
/// 微信路径版本号正则表达式
/// </summary>
/// <returns></returns>
[GeneratedRegex(@"\[\d+(\.\d+)*\]$")]
private static partial Regex WeChatVersionRegex();

public static void WriteBytesToFile(string filePath, byte[] bytes)
{
using var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None);
Expand Down

0 comments on commit 043136a

Please sign in to comment.