fix(url): simplify URL parameter extraction
Refactored URL parameter extraction to use the URL API, enhancing readability and maintainability. Improved reliability by leveraging built-in methods, which are less error-prone than regex-based extraction.
This commit is contained in:
parent
a7368163bf
commit
c3dff2394c
1 changed files with 3 additions and 6 deletions
|
@ -14,12 +14,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
|
||||||
// Function to get URL parameters
|
// Function to get URL parameters
|
||||||
function getUrlParameter(name) {
|
function getUrlParameter(name) {
|
||||||
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
url = document.location.href;
|
||||||
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
|
urlobj = new URL(url)
|
||||||
var results = regex.exec(location.search);
|
return urlobj.searchParams.get(name);
|
||||||
return results === null
|
|
||||||
? ""
|
|
||||||
: decodeURIComponent(results[1].replace(/\+/g, " "));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the 'embed' parameter is set to '1'
|
// Check if the 'embed' parameter is set to '1'
|
||||||
|
|
Loading…
Reference in a new issue