Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (options.dataType === 'json' && (!options.headers || !options.headers.Accept)) {
xhr.setRequestHeader('Accept', 'application/json');
}
// Additional headers
if (options.headers) {
Object.keys(options.headers).forEach((headerName) => {
xhr.setRequestHeader(headerName, options.headers[headerName]);
});
}
// Check for crossDomain
if (typeof options.crossDomain === 'undefined') {
// eslint-disable-next-line
options.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(options.url) && RegExp.$2 !== window.location.host;
}
if (!options.crossDomain) {
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
}
if (options.xhrFields) {
Utils.extend(xhr, options.xhrFields);
}
let xhrTimeout;
// Handle XHR
xhr.onload = function onload() {
if (xhrTimeout) clearTimeout(xhrTimeout);
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) {
parseUrlQuery(url) {
const query = {};
let urlToParse = url || window.location.href;
let i;
let params;
let param;
let length;
if (typeof urlToParse === 'string' && urlToParse.length) {
urlToParse = urlToParse.indexOf('?') > -1 ? urlToParse.replace(/\S*\?/, '') : '';
params = urlToParse.split('&').filter((paramsPart) => paramsPart !== '');
length = params.length;
for (i = 0; i < length; i += 1) {
param = params[i].replace(/#\S+/g, '').split('=');
query[decodeURIComponent(param[0])] = typeof param[1] === 'undefined' ? undefined : decodeURIComponent(param[1]) || '';
}
}
return query;
},
getPathValues() {
const pathArray = window.location.pathname.slice(1).split('/').filter(part => part !== '');
const total = pathArray.length;
const key = pathArray[total - 2];
const value = pathArray[total - 1];
return { key, value };
},
setHistory(key, index) {
getPathValues() {
const pathArray = window.location.pathname.slice(1).split('/').filter((part) => part !== '');
const total = pathArray.length;
const key = pathArray[total - 2];
const value = pathArray[total - 1];
return { key, value };
},
setHistory(key, index) {
function Request(requestOptions) {
const globalsNoCallbacks = Utils.extend({}, globals);
('beforeCreate beforeOpen beforeSend error complete success statusCode').split(' ').forEach((callbackName) => {
delete globalsNoCallbacks[callbackName];
});
const defaults = Utils.extend({
url: window.location.toString(),
method: 'GET',
data: false,
async: true,
cache: true,
user: '',
password: '',
headers: {},
xhrFields: {},
statusCode: {},
processData: true,
dataType: 'text',
contentType: 'application/x-www-form-urlencoded',
timeout: 0,
}, globalsNoCallbacks);
const options = Utils.extend({}, defaults, requestOptions);
function Request(requestOptions) {
const globalsNoCallbacks = Utils.extend({}, globals);
('beforeCreate beforeOpen beforeSend error complete success statusCode').split(' ').forEach((callbackName) => {
delete globalsNoCallbacks[callbackName];
});
const defaults = Utils.extend({
url: window.location.toString(),
method: 'GET',
data: false,
async: true,
cache: true,
user: '',
password: '',
headers: {},
xhrFields: {},
statusCode: {},
processData: true,
dataType: 'text',
contentType: 'application/x-www-form-urlencoded',
timeout: 0,
}, globalsNoCallbacks);
const options = Utils.extend({}, defaults, requestOptions);
setHistory(key, index) {
const swiper = this;
if (!swiper.history.initialized || !swiper.params.history.enabled) return;
const slide = swiper.slides.eq(index);
let value = History.slugify(slide.attr('data-history'));
if (!window.location.pathname.includes(key)) {
value = `${key}/${value}`;
}
const currentState = window.history.state;
if (currentState && currentState.value === value) {
return;
}
if (swiper.params.history.replaceState) {
window.history.replaceState({ value }, null, value);
} else {
window.history.pushState({ value }, null, value);
}
},
slugify(text) {
setHistory(key, index) {
const swiper = this;
if (!swiper.history.initialized || !swiper.params.history.enabled) return;
const slide = swiper.slides.eq(index);
let value = History.slugify(slide.attr('data-history'));
if (!window.location.pathname.includes(key)) {
value = `${key}/${value}`;
}
const currentState = window.history.state;
if (currentState && currentState.value === value) {
return;
}
if (swiper.params.history.replaceState) {
window.history.replaceState({ value }, null, value);
} else {
window.history.pushState({ value }, null, value);
}
},
slugify(text) {
setHistory(key, index) {
const swiper = this;
if (!swiper.history.initialized || !swiper.params.history.enabled) return;
const slide = swiper.slides.eq(index);
let value = History.slugify(slide.attr('data-history'));
if (!window.location.pathname.includes(key)) {
value = `${key}/${value}`;
}
const currentState = window.history.state;
if (currentState && currentState.value === value) {
return;
}
if (swiper.params.history.replaceState) {
window.history.replaceState({ value }, null, value);
} else {
window.history.pushState({ value }, null, value);
}
},
slugify(text) {
setHistory(key, index) {
const swiper = this;
if (!swiper.history.initialized || !swiper.params.history.enabled) return;
const slide = swiper.slides.eq(index);
let value = History.slugify(slide.attr('data-history'));
if (!window.location.pathname.includes(key)) {
value = `${key}/${value}`;
}
const currentState = window.history.state;
if (currentState && currentState.value === value) {
return;
}
if (swiper.params.history.replaceState) {
window.history.replaceState({ value }, null, value);
} else {
window.history.pushState({ value }, null, value);
}
},
slugify(text) {