Skip to content

Commit 32ac180

Browse files
Fix URL encode and decode #69
1 parent 99d9578 commit 32ac180

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

src/App.jsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,10 @@ function App() {
132132
// Parse URL params
133133
const parseParams = () => {
134134
// key as ranking criteria and value as list of conferences
135-
let res = {};
136-
137-
let paramList = window.location.search.substring(1).split("&");
138-
139-
// Map the paramList into an object with key as ranking criteria and value as list of conferences
140-
for (let param of paramList) {
141-
let tempSplit = param.split("=");
142-
const key = tempSplit[0], value = tempSplit[1];
143-
res[key] = value;
144-
}
145-
return res;
135+
const url = new URL(window.location.href)
136+
const paramsURL = new URLSearchParams(url.search);
137+
const params = Object.fromEntries(paramsURL.entries());
138+
return params;
146139
}
147140

148141
const params = parseParams();
@@ -216,14 +209,14 @@ function App() {
216209
if (csrParamList.length === allCsrConfNames.length - (allCoreSelected ? confsInBoth.length : 0)) {
217210
paramUrl += 'csrankings=all';
218211
} else if (csrParamList.length > 0) {
219-
paramUrl += `csrankings=${csrParamList.join(',')}`;
212+
paramUrl += `csrankings=${encodeURIComponent(csrParamList.join(','))}`;
220213
}
221214

222215
// Set core param
223216
if (coreParamList.length === allCoreConfNames.length - (allCsrSelected ? confsInBoth.length : 0)) {
224-
paramUrl += '&core=all';
217+
paramUrl += `&core=all`;
225218
} else if (coreParamList.length > 0) {
226-
paramUrl += `&core=${coreParamList.join(',')}`;
219+
paramUrl += `&core=${encodeURIComponent(coreParamList.join(','))}`;
227220
}
228221
const newUrl = window.location.pathname + '?' + paramUrl;
229222
window.history.replaceState(null, '', newUrl);

0 commit comments

Comments
 (0)