Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
timheuer committed Jun 20, 2022
2 parents 1d3e985 + 9895165 commit f57c296
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task<string> GetNgrokDownloadUrlAsync()

var html = await response.Content.ReadAsStringAsync();

var downloadLinkId = _is64Bit ? "dl-windows-amd64" : "dl-windows-386";
var downloadLinkId = "windows-dl-link";
var pattern = @"id=""" + downloadLinkId +
@"""(?:.|\s)*?[^>]+?href=""(http[s]?:\/\/[^""]*?)""";

Expand All @@ -54,7 +54,12 @@ public async Task<string> GetNgrokDownloadUrlAsync()
throw new NgrokDownloadException("Could not find ngrok download URL.");
}

return match.Groups[1].Value.Replace("&amp;", "&");
var archDownloadUri = match.Groups[1].Value.Replace("&amp;", "&");

// 07-Mar-2022: ngrok has dynamic download page now. This is a change to replace the arch version in their download URI
if (!_is64Bit) archDownloadUri = archDownloadUri.Replace("amd64", "386");

return archDownloadUri;
}

public async Task<Stream> DownloadNgrokAsync(string url = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public NgrokInstallerTest()
_mockHttpMessageHandler.When("https://ngrok.com/download").Respond("text/html", TestResponseContent);

var stream = new MemoryStream(SampleZip);
_mockHttpMessageHandler.When("https://fakedomain.io/ngrok64.zip").Respond("application/zip", stream);
_mockHttpMessageHandler.When("https://fakedomain.io/ngrok32.zip").Respond("application/zip", stream);
_mockHttpMessageHandler.When("https://fakedomain.io/ngrok-stable-windows-amd64.zip").Respond("application/zip", stream);
_mockHttpMessageHandler.When("https://fakedomain.io/ngrok-stable-windows-386.zip").Respond("application/zip", stream);

_mockHttpClient = _mockHttpMessageHandler.ToHttpClient();
}
Expand All @@ -33,15 +33,15 @@ public async Task TestGetNgrokDownloadUrlAsync()
{
var installer = new NgrokInstaller(_mockHttpClient, true);
var url = await installer.GetNgrokDownloadUrlAsync();
Assert.AreEqual("https://fakedomain.io/ngrok64.zip", url);
Assert.AreEqual("https://fakedomain.io/ngrok-stable-windows-amd64.zip", url);
}

[TestMethod]
public async Task TestGetNgrokDownloadUrl32BitAsync()
{
var installer = new NgrokInstaller(_mockHttpClient, false);
var url = await installer.GetNgrokDownloadUrlAsync();
Assert.AreEqual("https://fakedomain.io/ngrok32.zip", url);
Assert.AreEqual("https://fakedomain.io/ngrok-stable-windows-386.zip", url);
}

[TestMethod]
Expand Down Expand Up @@ -116,7 +116,7 @@ Get started with ngrok in just a few seconds.
<a id=""dl-darwin-amd64"" href=""https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-amd64.zip"" class=""download-btn"" onclick=""ga('send', 'event', 'ngrok', 'Downloaded', 'darwin_amd64');"">
<span>Mac OS X</span>
</a>
<a id=""dl-windows-amd64"" href=""https://fakedomain.io/ngrok64.zip"" class=""download-btn"" onclick=""ga('send', 'event', 'ngrok', 'Downloaded', 'windows_amd64');"">
<a id=""windows-dl-link"" href=""https://fakedomain.io/ngrok-stable-windows-amd64.zip"" class=""download-btn"" onclick=""ga('send', 'event', 'ngrok', 'Downloaded', 'windows_amd64');"">
<span>Windows</span>
</a>
<a id=""dl-linux-amd64"" href=""https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip"" class=""download-btn"" onclick=""ga('send', 'event', 'ngrok', 'Downloaded', 'linux_amd64');"">
Expand All @@ -125,7 +125,7 @@ Get started with ngrok in just a few seconds.
<a id=""dl-darwin-386"" href=""https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-386.zip"" class=""download-btn"" onclick=""ga('send', 'event', 'ngrok', 'Downloaded', 'darwin_386');"">
Mac (32-bit)
</a>
<a id=""dl-windows-386"" href=""https://fakedomain.io/ngrok32.zip"" class=""download-btn"" onclick=""ga('send', 'event', 'ngrok', 'Downloaded', 'windows_386');"">
<a id=""dl-windows-386"" href=""https://fakedomain.io/ngrok-stable-windows-386.zip"" class=""download-btn"" onclick=""ga('send', 'event', 'ngrok', 'Downloaded', 'windows_386');"">
Windows (32-bit)
</a>
<a id=""dl-linux-arm"" href=""https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip"" class=""download-btn"" onclick=""ga('send', 'event', 'ngrok', 'Downloaded', 'linux_arm');"">
Expand Down

0 comments on commit f57c296

Please sign in to comment.