From 85bc52812863cec3c43a8025541d221590d17cf1 Mon Sep 17 00:00:00 2001 From: Sorawee Porncharoenwase Date: Sat, 14 Oct 2023 20:07:47 +0700 Subject: [PATCH] refactor: modernize JS in scribble-common.js Browsers released within the last 5 years (the partial support tier according to https://github.com/racket/scribble/pull/240) support URLSearchParams, so we should use it. --- scribble-lib/scribble/scribble-common.js | 61 ++++-------------------- 1 file changed, 9 insertions(+), 52 deletions(-) diff --git a/scribble-lib/scribble/scribble-common.js b/scribble-lib/scribble/scribble-common.js index ceab368a70..bd9c245bcb 100644 --- a/scribble-lib/scribble/scribble-common.js +++ b/scribble-lib/scribble/scribble-common.js @@ -3,67 +3,24 @@ // Page Parameters ------------------------------------------------------------ var page_query_string = location.search.substring(1); - -var page_args = - ((function(){ - if (!page_query_string) return []; - var args = page_query_string.split(/[&;]/); - for (var i=0; i= 0) args[i] = [a.substring(0,p), a.substring(p+1)]; - else args[i] = [a, false]; - } - return args; - })()); +const page_args = new URLSearchParams(location.search); function GetPageArg(key, def) { - for (var i=0; i