From def3ca4f0e6f978790d5963dc51b2093c646c869 Mon Sep 17 00:00:00 2001 From: John Donaldson Date: Fri, 8 Nov 2019 19:46:56 +0000 Subject: [PATCH] Use native JS URL objects instead of wrangling everything by hand --- CHANGELOG.md | 2 ++ theme/moth.js | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b802aa..923392a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,3 +8,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - A changelog - Support for embedding Python libraries at the category or puzzle level +### Changed +- Use native JS URL objects instead of wrangling everything by hand diff --git a/theme/moth.js b/theme/moth.js index f6f99ec..2113b1b 100644 --- a/theme/moth.js +++ b/theme/moth.js @@ -62,7 +62,11 @@ function renderPuzzles(obj) { let a = document.createElement('a') i.appendChild(a) a.textContent = points - a.href = "puzzle.html?cat=" + cat + "&points=" + points + "&pid=" + id + let url = new URL("puzzle.html", window.location) + url.searchParams.set("cat", cat) + url.searchParams.set("points", points) + url.searchParams.set("pid", id) + a.href = url.toString() } }