Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var XHR = global.XMLHttpRequest = function() {
xhr.apply(this, arguments);
this._hackSend = this.send;
this.send = XHR.prototype.send;
this._hackOpen = this.open;
this.open = XHR.prototype.open;
// In browsers these default to null
this.onload = null;
this.onerror = null;
// jQuery checks for this property to see if XHR supports CORS
this.withCredentials = true;
};
var XHR = global.XMLHttpRequest = function() {
xhr.apply(this, arguments);
this._hackSend = this.send;
this.send = XHR.prototype.send;
var oldOpen = this.open;
this.open = function() {
var req = global.doneSsr.request;
var baseUri = req.url || "";
if ( req.protocol && req.get ) {
baseUri = req.protocol + '://' + req.get( "host" ) + baseUri;
}
var args = Array.prototype.slice.call(arguments);
var reqURL = args[1];
if ( reqURL && !fullUrl.test( reqURL ) ) {
args[1] = url.resolve( baseUri, reqURL );
}
var ShimXHR = function(){
XMLHttpRequest.apply(this, arguments);
var oldOpen = this.open;
this.open = function(method, url){
url = "file://" + process.cwd() + "/" + url;
arguments[1] = url;
return oldOpen.apply(this, arguments);
};
};