Added support for trailing slashes

Trailing slahes (LITTLEBIGPLANETPS3_XML/) now get automatically removed.
This commit is contained in:
McMistrzYT 2023-01-28 14:34:45 +01:00
parent 47af7d6929
commit 3b309103cd
3 changed files with 22 additions and 4 deletions

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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