Skip to content
Snippets Groups Projects
Commit bbc1fb85 authored by Jonas Leder's avatar Jonas Leder
Browse files

rewrite get parameter function

parent b8605da2
Branches
Tags
No related merge requests found
...@@ -2,18 +2,12 @@ if(window.location['pathname'] == "/post.html"){ ...@@ -2,18 +2,12 @@ if(window.location['pathname'] == "/post.html"){
loadPost(); loadPost();
} }
// return the value of the get parameter with the given name
function getParameter(key) { function getParameter(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
// Address of the current window var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
let address = window.location.search var results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
// Returns a URLSearchParams object instance
let parameterList = new URLSearchParams(address)
// Returning the respected value associated
// with the provided key
return parameterList.get(key)
} }
async function loadPost() { async function loadPost() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment