PageSourceSearch

https://www.spanishcourseinspain.com/static/js/cookie_post_csrf.js

js spanishcourseinspain.com collected 2026-09-26 06:17:04 UTC 1,780 bytes, 41 lines download raw bytes

1/*
2 * Código que permite el envío de peticiones POST de nuestro sitio sin ser bloqueados con
3 * el CSRFMiddleware.
4 * https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
5 */
6jQuery(document).ajaxSend(function(event, xhr, settings) {
7    function getCookie(name) {
8        var cookieValue = null;
9        if (document.cookie && document.cookie !== '') {
10            var cookies = document.cookie.split(';');
11            for (var i = 0; i < cookies.length; i++) {
12                var cookie = jQuery.trim(cookies[i]);
13                // Does this cookie string begin with the name we want?
14                if (cookie.substring(0, name.length + 1) == (name + '=')) {
15                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
16                    break;
17                }
18            }
19        }
20        return cookieValue;
21    }
22    function sameOrigin(url) {
23        // url could be relative or scheme relative or absolute
24        var host = document.location.host; // host + port
25        var protocol = document.location.protocol;
26        var sr_origin = '//' + host;
27        var origin = protocol + sr_origin;
28        // Allow absolute or scheme relative URLs to same origin
29        return (url == origin || url.slice(0, origin.length + 1) == origin + '/') ||
30            (url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin + '/') ||
31            // or any other URL that isn't scheme relative or absolute i.e relative.
32            !(/^(\/\/|http:|https:).*/.test(url));
33    }
34    function safeMethod(method) {
35        return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
36    }
37
38    if (!safeMethod(settings.type) && sameOrigin(settings.url)) {
39        xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
40    }
41});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.