Skip to content

Commit

Permalink
Merge pull request #129 from TheSecretOrganization/refactor-get-cookies
Browse files Browse the repository at this point in the history
refactor getCookie function in core
  • Loading branch information
croueAlec authored Sep 23, 2024
2 parents 4606cee + 206ed52 commit d695ea6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions nginx/src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ function submitForm(id, oncomplete, onerror) {
function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
const cookies = document.cookie.split(';').map(cookie => cookie.trim());
for (let cookie of cookies) {
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
Expand Down

0 comments on commit d695ea6

Please sign in to comment.