Commit 5c792ba1 authored by Chunchi Che's avatar Chunchi Che

fix url with

parent 81ae8d96
Pipeline #21773 passed with stages
in 12 minutes and 21 seconds
......@@ -38,7 +38,9 @@ export default function Login() {
setIp(event.target.value);
};
const handleSubmit = () => navigate(`/room/${player}/${passWd}/${ip}`);
// 因为萌卡服务器的房间密码会有`#`等特殊字符,因此这里用`encodeURIComponent`做下转义
const handleSubmit = () =>
navigate(`/room/${player}/${encodeURIComponent(passWd)}/${ip}`);
useEffect(() => {
// 如果开启了AI模式,直接进入房间
......
......@@ -44,7 +44,7 @@ const Mora = () => {
useEffect(() => {
// 若对局已经开始,自动跳转
if (meLife > 0) {
navigate(`/duel/${player}/${passWd}/${ip}`);
navigate(`/duel/${player}/${encodeURIComponent(passWd ?? "")}/${ip}`);
}
}, [meLife]);
......
......@@ -194,7 +194,7 @@ const WaitRoom = () => {
// 若当前玩家是房主并且对战双方都已准备完毕,跳转到猜拳页面;
// 否则停留在当前页面。
if (duelStart) {
navigate(`/mora/${player}/${passWd}/${ip}`);
navigate(`/mora/${player}/${encodeURIComponent(passWd ?? "")}/${ip}`);
}
}, [duelStart]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment