Add param to include HTTPS prefix in DetermineRemoteUrl method

This commit is contained in:
koko 2023-10-01 08:11:33 -04:00
commit c63284cb37
No known key found for this signature in database
GPG key ID: 48BB40C0F649D603
2 changed files with 6 additions and 3 deletions

View file

@ -192,7 +192,7 @@
<div class="ui black attached inverted segment">
<div class="ui container">
@{
string? remoteUrl = VersionHelper.DetermineRemoteUrl();
string? remoteUrl = VersionHelper.DetermineRemoteUrl(false);
}
<span>
@Model.Translate(BaseLayoutStrings.GeneratedBy, VersionHelper.FullVersion)

View file

@ -52,7 +52,8 @@ public static class VersionHelper
/// Determines the URL of the git remote. This doesn't return a complete URL and it's only really used for the
/// "Source Code" hyperlink in the BaseLayout. Use this with caution.
/// </summary>
public static string? DetermineRemoteUrl()
/// <param name="includePrefix">Include the "https://" prefix in the returned URL.</param>
public static string? DetermineRemoteUrl(bool includePrefix = true)
{
string? remoteUnparsedUrl = null;
string? remoteParsedUrl = null;
@ -66,7 +67,9 @@ public static class VersionHelper
}
else if (remoteUnparsedUrl.Contains("https://"))
{
remoteParsedUrl = remoteUnparsedUrl.Replace("https://", "").Split(".git").FirstOrDefault();
remoteParsedUrl = includePrefix
? remoteUnparsedUrl.Split(".git").FirstOrDefault()
: remoteUnparsedUrl.Replace("https://", "").Split(".git").FirstOrDefault();
}
return remoteParsedUrl;