Skip to content

Commit

Permalink
Fix url encoding
Browse files Browse the repository at this point in the history
wow that was annoying
  • Loading branch information
Cattn committed Jul 30, 2024
1 parent 59b4bd9 commit f576060
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html lang="en" data-theme="dark">
<head>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-PS49ZXBGRW"></script>
<script>
Expand Down
8 changes: 5 additions & 3 deletions src/routes/play/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
if (browser) {
const urlParams = new URLSearchParams(window.location.search);
game = urlParams.get("game");
game = decodeURIComponent(urlParams.get("game"));
core = urlParams.get("core");
title = urlParams.get("title");
url = base + "/launch.html?core=" + core + "&game=" + game;
title = decodeURIComponent(urlParams.get("title"));
let endURL = encodeURIComponent(game)
url = base + "/launch.html?core=" + core + "&game=" + endURL;
console.log(url);
}
function toggleFullScreen() {
Expand Down
6 changes: 3 additions & 3 deletions src/routes/singleplayer/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
.then((data) => {
if (data.games) {
games[consoleName] = data.games;
currentSrc = selectedConsole.source + "/" + selectedConsole.folder;
currentSrc = selectedConsole.source + "" + selectedConsole.folder;
currentConsole = selectedConsole.core;
}
})
Expand Down Expand Up @@ -148,7 +148,7 @@
{#if games[selectedStatus.value] && games[selectedStatus.value].length > 0}
{#each games[selectedStatus.value] as game (game.file)}
{#if game.title.toLowerCase().includes(searchTerm.toLowerCase())}
<a href="{base}/play?title={game.title}&core={currentConsole}&game={currentSrc}/{game.file}" class="group old-1 rounded-lg border px-4 py-4 shadow-sm hover:border-gray-400 hover:shadow-md focus-within:border-gray-500 focus-within:shadow-md">
<a href="{base}/play?title={encodeURIComponent(game.title)}&core={currentConsole}&game={encodeURIComponent(`${currentSrc}/${game.file}`)}" class="group old-1 rounded-lg border px-4 py-4 shadow-sm hover:border-gray-400 hover:shadow-md focus-within:border-gray-500 focus-within:shadow-md">
<h2 class="text-lg font-bold mb-2">{game.title}</h2>
<p class="text-sm text-muted-foreground">{selectedStatus.label}</p>
</a>
Expand All @@ -162,7 +162,7 @@
{#if games[console.name] && games[console.name].length > 0}
{#each games[console.name] as game (game.file)}
{#if game.title.toLowerCase().includes(searchTerm.toLowerCase())}
<a href="{base}/play?core={currentConsole}&game={currentSrc}/{game.file}" class="group old-1 rounded-lg border px-4 py-4 shadow-sm hover:border-gray-400 hover:shadow-md focus-within:border-gray-500 focus-within:shadow-md">
<a href="{base}/play?core={currentConsole}&game={encodeURI(currentSrc)}/{encodeURI(game.file)}" class="group old-1 rounded-lg border px-4 py-4 shadow-sm hover:border-gray-400 hover:shadow-md focus-within:border-gray-500 focus-within:shadow-md">
<h2 class="text-lg font-bold mb-2">{game.title}</h2>
<p class="text-sm text-muted-foreground">{selectedStatus.label}</p>
</a>
Expand Down
2 changes: 1 addition & 1 deletion static/launch.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>
<script>
const urlParams = new URLSearchParams(window.location.search);
game = urlParams.get("game");
game = decodeURIComponent(urlParams.get("game"));
core = urlParams.get("core");
window.EJS_player = '#game';
window.EJS_core = core;
Expand Down

0 comments on commit f576060

Please sign in to comment.