mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
js: Percent-encode game IDs in URLs and decode them again on input
This is necessary to allow all random seeds to round-trip properly. It's probably not currently necessary for descriptive game IDs, but it won't hurt. I've deliberately gone for encoding only those characters that are not valid in fragment identifiers to minimise the ugliness of the generated URLs. For slightly interesting historical reasons, '#' is not valid in a fragment identifier, so all random seed links end up a little bit ugly.
This commit is contained in:
@ -165,13 +165,13 @@ mergeInto(LibraryManager.library, {
|
||||
* the random seed permalink.
|
||||
*/
|
||||
js_update_permalinks: function(desc, seed) {
|
||||
desc = UTF8ToString(desc);
|
||||
desc = encodeURI(UTF8ToString(desc)).replaceAll("#", "%23");
|
||||
permalink_desc.href = "#" + desc;
|
||||
|
||||
if (seed == 0) {
|
||||
permalink_seed.style.display = "none";
|
||||
} else {
|
||||
seed = UTF8ToString(seed);
|
||||
seed = encodeURI(UTF8ToString(seed)).replaceAll("#", "%23");;
|
||||
permalink_seed.href = "#" + seed;
|
||||
permalink_seed.style.display = "";
|
||||
}
|
||||
|
Reference in New Issue
Block a user