Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(function () {
'use strict';
exports.XMLHttpRequest = global.XMLHttpRequest;
exports.FormData = global.FormData;
if (!exports.XMLHttpRequest) {
var xhr = require("xhr");
exports.XMLHttpRequest = xhr.XMLHttpRequest;
exports.FormData = xhr.FormData;
}
function normalizeName(name) {
if (typeof name !== 'string') {
name = name.toString();
}
if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
throw new TypeError('Invalid character in header field name')
}
return name.toLowerCase()
}
function normalizeValue(value) {
if (typeof value !== 'string') {
value = value.toString();
}
(function () {
'use strict';
exports.XMLHttpRequest = global.XMLHttpRequest;
exports.FormData = global.FormData;
if (!exports.XMLHttpRequest) {
var xhr = require("xhr");
exports.XMLHttpRequest = xhr.XMLHttpRequest;
exports.FormData = xhr.FormData;
}
function normalizeName(name) {
if (typeof name !== 'string') {
name = name.toString();
}
if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
throw new TypeError('Invalid character in header field name')
}
return name.toLowerCase()
}
function normalizeValue(value) {
if (typeof value !== 'string') {
value = value.toString();
}
(function () {
'use strict';
exports.XMLHttpRequest = global.XMLHttpRequest;
exports.FormData = global.FormData;
if (!exports.XMLHttpRequest) {
var xhr = require("xhr");
exports.XMLHttpRequest = xhr.XMLHttpRequest;
exports.FormData = xhr.FormData;
}
function normalizeName(name) {
if (typeof name !== 'string') {
name = name.toString();
}
if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
throw new TypeError('Invalid character in header field name')
}
return name.toLowerCase()
}
function normalizeValue(value) {
if (typeof value !== 'string') {
value = value.toString();
}
configurable: true
});
}
if (global.__snapshot) {
var timer = require("timer");
global.setTimeout = timer.setTimeout;
global.clearTimeout = timer.clearTimeout;
global.setInterval = timer.setInterval;
global.clearInterval = timer.clearInterval;
var dialogs = require("ui/dialogs");
global.alert = dialogs.alert;
global.confirm = dialogs.confirm;
global.prompt = dialogs.prompt;
var xhr = require("xhr");
global.XMLHttpRequest = xhr.XMLHttpRequest;
global.FormData = xhr.FormData;
var fetch = require("fetch");
global.fetch = fetch.fetch;
global.Headers = fetch.Headers;
global.Request = fetch.Request;
global.Response = fetch.Response;
}
else {
registerOnGlobalContext("setTimeout", "timer");
registerOnGlobalContext("clearTimeout", "timer");
registerOnGlobalContext("setInterval", "timer");
registerOnGlobalContext("clearInterval", "timer");
registerOnGlobalContext("alert", "ui/dialogs");
registerOnGlobalContext("confirm", "ui/dialogs");
registerOnGlobalContext("prompt", "ui/dialogs");
registerOnGlobalContext("XMLHttpRequest", "xhr");
registerOnGlobalContext("FormData", "xhr");
var timer = require("timer");
var dialogs = require("ui/dialogs");
var xhr = require("xhr");
var fetch_1 = require("fetch");
snapshotGlobals = snapshotGlobals || {
setTimeout: timer.setTimeout,
clearTimeout: timer.clearTimeout,
setInterval: timer.setInterval,
clearInterval: timer.clearInterval,
alert: dialogs.alert,
confirm: dialogs.confirm,
prompt: dialogs.prompt,
login: dialogs.login,
action: dialogs.action,
XMLHttpRequest: xhr.XMLHttpRequest,
FormData: xhr.FormData,
fetch: fetch_1.fetch,
Headers: fetch_1.Headers,
Request: fetch_1.Request,
Response: fetch_1.Response,
};
}
var consoleModule = require("console").Console;
global.console = global.console || new consoleModule();
Object.assign(global, snapshotGlobals);
}
else {
registerOnGlobalContext("setTimeout", "timer");
registerOnGlobalContext("clearTimeout", "timer");
registerOnGlobalContext("setInterval", "timer");
registerOnGlobalContext("clearInterval", "timer");
registerOnGlobalContext("alert", "ui/dialogs");