Skip to content

Commit

Permalink
encode the servername if prefix is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
zefanjajobse committed Nov 28, 2024
1 parent d4677ef commit 2bbad82
Showing 1 changed file with 48 additions and 54 deletions.
102 changes: 48 additions & 54 deletions src/components/routes/Servers/Detailed/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function Results(props: Views): React.ReactElement {
.reduce((acc, key) => ((acc[key] = modCategories[key]), acc), {});
let widgetReturn =
props.getter === "name"
? props.serverName
? encodeURIComponent(props.serverName)
: encodeURIComponent(stats?.prefix);
let widgetItem = "name";

Expand Down Expand Up @@ -249,9 +249,8 @@ export function Results(props: Views): React.ReactElement {
<p className={Mainstyles.description} style={{ marginTop: "6px" }}>
{t("servers.permLink")}{" "}
<CopyToClipboard
message={`https://gametools.network/servers/${
props.game
}/name/${encodeURIComponent(stats?.prefix)}/pc`}
message={`https://gametools.network/servers/${props.game
}/name/${encodeURIComponent(stats?.prefix)}/pc`}
stateTranslation={"states"}
/>
</p>
Expand Down Expand Up @@ -296,27 +295,27 @@ export function Results(props: Views): React.ReactElement {
<div className="align">
{loading
? [...Array(4)].map((key, index) => (
<MapRotationItem
key={key}
stats={{
image: "",
mapname: t("loading"),
mode: t("notApplicable"),
index: index,
}}
index={index}
/>
))
<MapRotationItem
key={key}
stats={{
image: "",
mapname: t("loading"),
mode: t("notApplicable"),
index: index,
}}
index={index}
/>
))
: stats?.rotation?.map(
(key: ServerRotation, index: number) =>
key && (
<MapRotationItem
key={index}
stats={key}
index={index}
/>
),
)}
(key: ServerRotation, index: number) =>
key && (
<MapRotationItem
key={index}
stats={key}
index={index}
/>
),
)}
</div>
</>
)}
Expand Down Expand Up @@ -371,24 +370,24 @@ export function Results(props: Views): React.ReactElement {
isError={props.error}
/>
) : // older titles
stats?.ip && stats?.port ? (
<BfListServerPlayerList
game={props.game}
serverIp={stats?.ip}
serverPort={stats?.hostport || stats?.port}
/>
) : (
props.game.includes("marne") && (
<MarnePlayerList
stats={stats}
game={props?.game}
gameId={stats?.gameId}
isLoading={props.loading}
isError={props.error}
stats?.ip && stats?.port ? (
<BfListServerPlayerList
game={props.game}
serverIp={stats?.ip}
serverPort={stats?.hostport || stats?.port}
/>
// <Bf3ServerPlayerlist players={stats?.players} game="bf1" />
)
)}
) : (
props.game.includes("marne") && (
<MarnePlayerList
stats={stats}
game={props?.game}
gameId={stats?.gameId}
isLoading={props.loading}
isError={props.error}
/>
// <Bf3ServerPlayerlist players={stats?.players} game="bf1" />
)
)}
</>
)}
{/* bf4 */}
Expand Down Expand Up @@ -438,7 +437,7 @@ export function Results(props: Views): React.ReactElement {
value.values[0].readableSettingName,
)}
</b>
: {}
: { }
{value.values[1].readableSettingName}
</p>
</div>
Expand Down Expand Up @@ -549,13 +548,10 @@ export function Results(props: Views): React.ReactElement {
>
{t(`servers.iframe.${element}`)}{" "}
<CopyToClipboard
message={`<iframe title="Server playercount" src="https://widgets.gametools.network/servers/${element}/${
props.game
}/${widgetItem}/${widgetReturn}/${
props.platform
}?lng=${getLanguage()}" height="${
widgetSize[index]
}px" width="700px" frameborder="0" allowtransparency="true"></iframe>`}
message={`<iframe title="Server playercount" src="https://widgets.gametools.network/servers/${element}/${props.game
}/${widgetItem}/${widgetReturn}/${props.platform
}?lng=${getLanguage()}" height="${widgetSize[index]
}px" width="700px" frameborder="0" allowtransparency="true"></iframe>`}
stateTranslation={"servers.iframe.states"}
/>
</p>
Expand All @@ -564,11 +560,9 @@ export function Results(props: Views): React.ReactElement {
) : (
<iframe
title="Server playercount"
src={`https://widgets.gametools.network/servers/${element}/${
props.game
}/${widgetItem}/${widgetReturn}/${
props.platform
}?lng=${getLanguage()}`}
src={`https://widgets.gametools.network/servers/${element}/${props.game
}/${widgetItem}/${widgetReturn}/${props.platform
}?lng=${getLanguage()}`}
style={{
maxWidth: "700px",
backgroundColor: "transparent",
Expand Down

0 comments on commit 2bbad82

Please sign in to comment.