Used strict comparison in docs/ref/csrf.txt's JavaScript.

This commit is contained in:
Camilo Nova 2016-06-28 11:51:51 -05:00 committed by Tim Graham
parent 49b4596cb4
commit 222e1334bf
1 changed files with 2 additions and 2 deletions

View File

@ -83,12 +83,12 @@ Acquiring the token is straightforward:
// using jQuery // using jQuery
function getCookie(name) { function getCookie(name) {
var cookieValue = null; var cookieValue = null;
if (document.cookie && document.cookie != '') { if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';'); var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) { for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]); var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want? // Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) { if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break; break;
} }