Skip to content

Commit

Permalink
Http to https translation for GitHub pages urls (#6626)
Browse files Browse the repository at this point in the history
  • Loading branch information
skofman1 committed Nov 6, 2018
1 parent 56126b1 commit 663cd34
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/NuGetGallery/Helpers/UriExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static bool IsGitProtocol(this Uri uri)

public static bool IsDomainWithHttpsSupport(this Uri uri)
{
return IsGitHubUri(uri) || IsCodeplexUri(uri) || IsMicrosoftUri(uri);
return IsGitHubUri(uri) || IsGitHubPagerUri(uri) || IsCodeplexUri(uri) || IsMicrosoftUri(uri);
}

public static bool IsGitHubUri(this Uri uri)
Expand All @@ -35,6 +35,12 @@ public static bool IsGitHubUri(this Uri uri)
string.Equals(uri.Host, "github.com", StringComparison.OrdinalIgnoreCase);
}

public static bool IsGitHubPagerUri(this Uri uri)
{
return uri.Authority.EndsWith(".github.51.al", StringComparison.OrdinalIgnoreCase) ||
uri.Authority.EndsWith(".github.io", StringComparison.OrdinalIgnoreCase);
}

private static bool IsCodeplexUri(this Uri uri)
{
return uri.Authority.EndsWith(".codeplex.com", StringComparison.OrdinalIgnoreCase) ||
Expand Down
1 change: 1 addition & 0 deletions tests/NuGetGallery.Facts/Helpers/HtmlExtensionsFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void EncodesHtml()
[InlineData("http://github.com/nuget is my site.", "<a href=\"https://github.com/nuget\" rel=\"nofollow\">https://github.com/nuget</a> is my site.")]
[InlineData("My site is http://www.asp.net best site ever!", "My site is <a href=\"https://www.asp.net/\" rel=\"nofollow\">https://www.asp.net/</a> best site ever!")]
[InlineData("My site is http:////github.com bad url", "My site is http:////github.com bad url")]
[InlineData("Im using github pages! http://mypage.github.com/stuff.", "Im using github pages! <a href=\"https://mypage.github.com/stuff\" rel=\"nofollow\">https://mypage.github.com/stuff</a>.")]
public void ConvertsUrlsToLinks(string input, string expected)
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public void ItDeterminesRepositoryKind(string repoUrl, string repoType, Reposito
[InlineData("http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx", "https://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx")]
[InlineData("http://microsoft.com/iconurl/9594202", "https://microsoft.com/iconurl/9594202")]
[InlineData("http://microsoft.com:80/", "https://microsoft.com/")]
[InlineData("http://githubpages.github.io/my.page", "https://githubpages.github.io/my.page")]
[InlineData("http://githubpages.github.com", "https://githubpages.github.com/")]
public void ItInitializesProjectUrl(string projectUrl, string expected)
{
var package = new Package
Expand All @@ -99,6 +101,8 @@ public void ItInitializesProjectUrl(string projectUrl, string expected)
[InlineData("http://aspnetwebstack.codeplex.com/license", "https://aspnetwebstack.codeplex.com/license")]
[InlineData("http://go.microsoft.com/?linkid=9809688", "https://go.microsoft.com/?linkid=9809688")]
[InlineData("http://github.com/url", "https://github.com/url")]
[InlineData("http://githubpages.github.io/my.page/license.html", "https://githubpages.github.io/my.page/license.html")]
[InlineData("http://githubpages.github.com", "https://githubpages.github.com/")]
public void ItInitializesLicenseUrl(string licenseUrl, string expected)
{
var package = new Package
Expand Down

0 comments on commit 663cd34

Please sign in to comment.