Use correct product name in `User-Agent` value

This commit is contained in:
YoshiRulz 2024-09-02 05:31:19 +10:00
parent cda23dd38e
commit e9aba0557e
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 7 additions and 1 deletions

View File

@ -43,6 +43,10 @@ namespace BizHawk.Common.StringExtensions
public static bool In(this string str, params string[] options) =>
options.Any(opt => string.Equals(opt, str, StringComparison.OrdinalIgnoreCase));
/// <returns>a copy of <paramref name="raw"/> with all characters outside <c>[0-9A-Za-z]</c> removed</returns>
public static string OnlyAlphanumeric(this string raw)
=> string.Concat(raw.Where(static c => c is (>= '0' and <= '9') or (>= 'A' and <= 'Z') or (>= 'a' and <= 'z')));
/// <returns>
/// <paramref name="str"/> with the first char removed, or
/// the original <paramref name="str"/> if the first char of <paramref name="str"/> is not <paramref name="prefix"/>

View File

@ -39,7 +39,9 @@ namespace BizHawk.Common
CustomBuildString = lines[0];
}
}
UserAgentEscaped = $"BizHawk/{MainVersion}{(DeveloperBuild ? "-dev" : string.Empty)}";
UserAgentEscaped = $"{
(string.IsNullOrWhiteSpace(CustomBuildString) ? "EmuHawk" : CustomBuildString!.OnlyAlphanumeric())
}/{MainVersion}{(DeveloperBuild ? "-dev" : string.Empty)}";
}
public static (string Label, string TargetURI) GetGitCommitLink()