Use native JS URL objects instead of wrangling everything by hand

This commit is contained in:
John Donaldson 2019-11-08 19:46:56 +00:00
parent dc7d10b12b
commit def3ca4f0e
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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()
}
}