Skip to content

Commit 7d5ef9e

Browse files
committed
Add password input field and update URL generation logic in SSH link generator
1 parent ec9c157 commit 7d5ef9e

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

index.html

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
const [endpoint, setEndpoint] = useState(location.href + "connect.php");
158158
const [port, setPort] = useState("10022");
159159
const [destination, setDestination] = useState("linuxserver.io@localhost");
160+
const [password, setPassword] = useState("");
160161
const [key, setKey] = useState("");
161162
const [copied, setCopied] = useState(false);
162163

@@ -168,12 +169,22 @@
168169
const url = new URL(base);
169170
url.searchParams.set("port", port);
170171
url.searchParams.set("destination", destination);
171-
url.searchParams.set("key", key);
172+
if (password.trim()) {
173+
url.searchParams.set("password", password);
174+
} else {
175+
url.searchParams.delete("password");
176+
}
177+
178+
if (key.trim()) {
179+
url.searchParams.set("key", key);
180+
} else {
181+
url.searchParams.delete("key");
182+
}
172183
return url.toString();
173184
} catch {
174185
return "";
175186
}
176-
}, [endpoint, port, destination, key]);
187+
}, [endpoint, port, destination, password, key]);
177188

178189
const handleCopy = async () => {
179190
if (!generatedUrl) return;
@@ -223,12 +234,22 @@ <h1>SSH Link Generator</h1>
223234
/>
224235
</label>
225236

237+
<label>
238+
Password
239+
<input
240+
type="password"
241+
value={password}
242+
onChange={(e) => setPassword(e.target.value)}
243+
placeholder="接続パスワード(任意)"
244+
/>
245+
</label>
246+
226247
<label>
227248
Key
228249
<textarea
229250
value={key}
230251
onChange={(e) => setKey(e.target.value)}
231-
placeholder="秘密鍵の文字列"
252+
placeholder="秘密鍵の文字列(任意)"
232253
/>
233254
</label>
234255
</div>

0 commit comments

Comments
 (0)