From 7eb1bf732d4439ad6e74367027bad864b78b6494 Mon Sep 17 00:00:00 2001 From: Kipstz Avenger <140314732+Kipstz@users.noreply.github.com> Date: Sun, 3 Aug 2025 20:49:46 +0200 Subject: [PATCH] Fix invite link in Join Lobby (#1695) Closes #1694 ## Description: Currently when you paste the invitation ( [https://openfront.io#join=QwIr5aK4](https://openfront.io/#join=QwIr5aK4) ) it puts undefined in the input so I made this issue to make a PR and fix the problem. image ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I have read and accepted the CLA agreement (only required once). ## Please put your Discord username so you can be contacted if a bug or regression is found: kipstzz --- src/client/JoinPrivateLobbyModal.ts | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/client/JoinPrivateLobbyModal.ts b/src/client/JoinPrivateLobbyModal.ts index 1b631be87..1c875a7e7 100644 --- a/src/client/JoinPrivateLobbyModal.ts +++ b/src/client/JoinPrivateLobbyModal.ts @@ -135,14 +135,25 @@ export class JoinPrivateLobbyModal extends LitElement { ); } - private setLobbyId(id: string) { - if (id.startsWith("http")) { - this.lobbyIdInput.value = id.split("join/")[1]; + private extractLobbyIdFromUrl(input: string): string { + if (input.startsWith("http")) { + if (input.includes("#join=")) { + const params = new URLSearchParams(input.split("#")[1]); + return params.get("join") ?? input; + } else if (input.includes("join/")) { + return input.split("join/")[1]; + } else { + return input; + } } else { - this.lobbyIdInput.value = id; + return input; } } + private setLobbyId(id: string) { + this.lobbyIdInput.value = this.extractLobbyIdFromUrl(id); + } + private handleChange(e: Event) { const value = (e.target as HTMLInputElement).value.trim(); this.setLobbyId(value); @@ -151,15 +162,7 @@ export class JoinPrivateLobbyModal extends LitElement { private async pasteFromClipboard() { try { const clipText = await navigator.clipboard.readText(); - - let lobbyId: string; - if (clipText.startsWith("http")) { - lobbyId = clipText.split("join/")[1]; - } else { - lobbyId = clipText; - } - - this.lobbyIdInput.value = lobbyId; + this.setLobbyId(clipText); } catch (err) { console.error("Failed to read clipboard contents: ", err); }