This commit is contained in:
mc 2024-01-27 13:49:11 -08:00 committed by GitHub
commit 52e51641bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -132,6 +132,7 @@ public class FilePatchForm : Form {
Gui.CreateOkDialog("Error occurred while patching", "An error occured while patching:\n" + e); Gui.CreateOkDialog("Error occurred while patching", "An error occured while patching:\n" + e);
return; return;
} }
this.serverUrl.Text = this.serverUrl.Text.TrimEnd('/');
Gui.CreateOkDialog("Success!", "The Server URL has been patched to " + this.serverUrl.Text); Gui.CreateOkDialog("Success!", "The Server URL has been patched to " + this.serverUrl.Text);
} }

View file

@ -21,8 +21,10 @@ public static class Patcher {
public static byte[] PatchData(byte[] data, string serverUrl) { public static byte[] PatchData(byte[] data, string serverUrl) {
#region Validation #region Validation
if(serverUrl.EndsWith('/')) { // If server URL contains a trailing slash, loop until it's gone.
throw new ArgumentException("URL must not contain a trailing slash!"); while (serverUrl.EndsWith('/'))
{
serverUrl = serverUrl.Remove(serverUrl.Length - 1);
} }
// Attempt to create URI to see if it's valid // Attempt to create URI to see if it's valid