diff --git a/UnionPatcher.Gui/Forms/FilePatchForm.cs b/UnionPatcher.Gui/Forms/FilePatchForm.cs index a52e04d..db1bb4f 100644 --- a/UnionPatcher.Gui/Forms/FilePatchForm.cs +++ b/UnionPatcher.Gui/Forms/FilePatchForm.cs @@ -132,7 +132,15 @@ public class FilePatchForm : Form { Gui.CreateOkDialog("Error occurred while patching", "An error occured while patching:\n" + e); return; } + + // Purely for the dialog box to show the correct URL. Actual patcher has this too. + // If server URL contains a trailing slash, loop until it's gone. + string formattedUrl = this.serverUrl.Text; + while (formattedUrl.EndsWith('/')) + { + formattedUrl = formattedUrl.Remove(formattedUrl.Length - 1); + } - Gui.CreateOkDialog("Success!", "The Server URL has been patched to " + this.serverUrl.Text); + Gui.CreateOkDialog("Success!", "The Server URL has been patched to " + formattedUrl); } } diff --git a/UnionPatcher.Gui/Forms/RemotePatchForm.cs b/UnionPatcher.Gui/Forms/RemotePatchForm.cs index 7354ea9..16301d6 100644 --- a/UnionPatcher.Gui/Forms/RemotePatchForm.cs +++ b/UnionPatcher.Gui/Forms/RemotePatchForm.cs @@ -73,7 +73,15 @@ public class RemotePatchForm : Form return; } - Gui.CreateOkDialog("Success!", $"The Server URL for {this.lbpGameID.Text} on the PS3 at {this.ps3LocalIP.Text} has been patched to {this.serverUrl.Text}"); + // Purely for the dialog box to show the correct URL. Actual patcher has this too. + // If server URL contains a trailing slash, loop until it's gone. + string formattedUrl = this.serverUrl.Text; + while (formattedUrl.EndsWith('/')) + { + formattedUrl = formattedUrl.Remove(formattedUrl.Length - 1); + } + + Gui.CreateOkDialog("Success!", $"The Server URL for {this.lbpGameID.Text} on the PS3 at {this.ps3LocalIP.Text} has been patched to {formattedUrl}"); }; return control; diff --git a/UnionPatcher/Patcher.cs b/UnionPatcher/Patcher.cs index 7593974..662b7ec 100644 --- a/UnionPatcher/Patcher.cs +++ b/UnionPatcher/Patcher.cs @@ -21,8 +21,10 @@ public static class Patcher { public static byte[] PatchData(byte[] data, string serverUrl) { #region Validation - if(serverUrl.EndsWith('/')) { - throw new ArgumentException("URL must not contain a trailing slash!"); + // If server URL contains a trailing slash, loop until it's gone. + while (serverUrl.EndsWith('/')) + { + serverUrl = serverUrl.Remove(serverUrl.Length - 1); } // Attempt to create URI to see if it's valid