Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return _.reduce(ports, (ports, port, name) => {
port = XRegExp.exec(port, regex_port);
port.protocol = port.protocol || "tcp";
// TODO: Add support a bind ip
var conf = { HostIp: config("agent:dns:ip") };
if (port.public)
conf.HostPort = port.public;
ports[name] = {
config : conf,
name : port.private + "/" + port.protocol,
private: port.private
};
return ports;
}, {})
}
Route.prototype.match = function (url) {
//make sure the last `/` is trimmed off the url, otherwise last splash can falsely be empty string, i.e. ''
if (url.slice(-1) == '/') {
url = url.slice(0, -1);
}
var path = this.path;
// Matches url?
// Performance: If there isn't any regex characters `*:()` then simply check for equality
if (path.indexOf('*') == -1 && path.indexOf(':') == -1 && path.indexOf('(') == -1 && path.indexOf(')') == -1 && path == url) {
return true;
}
var regex = this.regex ? this.regex : this.compile();
var matches = XRegExp.exec(url, regex);
if (matches == null) return false;
// Initialise the return value (found parameters)
var self = this;
var RequestParams = {_masked:[]};
// All named parameters
self.params.forEach(function (param) {
if (matches[param] == undefined) return;
RequestParams[param] = matches[param];
});
// All masked/unnamed parameters
var masked = self.masked;
masked.every(function (maskedName) {
if (matches[maskedName] == undefined) return true;
// Strip any whitespace at the end
line = line.replace(/\s+$/g);
if (!type) {
type = util.getLogMessageType(line);
}
if (!type || !line.length) {
return;
}
var message = {};
var regex = PATTERNS[type];
try {
var match = XRegExp.exec(line, regex);
var captureNames = regex.xregexp.captureNames;
var fields = ['level', 'timestamp', 'pid', 'tid', 'tag', 'message'];
fields.forEach(function(field) {
if (captureNames.indexOf(field) >= 0) {
message[field] = match[field];
}
});
messages.push(message);
} catch (e) {
badLines++;
}
});
FindHashtags.prototype._findNextMatch = function () {
this._currentMatch = XRegExp.exec(this._content, hashtagExp, this._nextMatchPosition);
};
return _.reduce(ports, (function(ports, port, name) {
if (port == null)
return ports;
port = XRegExp.exec(port, regex_port);
port.protocol = port.protocol || "tcp";
var conf = {HostIp: config("agent:dns:ip")};
if (port.public)
conf.HostPort = port.public;
ports[name] = {
config: conf,
name: port.private + "/" + port.protocol,
private: port.private
};
return ports;
}), {});
},
function getEndpointDescription(endpoint) {
var xRegExp = XRegExp('(?[^/]+)/(?[^#]+)#(?.+)')
var result = XRegExp.exec(endpoint, xRegExp)
return {
version: result.version,
moduleName: result.moduleName,
methodName: result.methodName
}
}
var js = compiled.js;
if (params.sourceMapURL !== undefined)
js += "\n//# sourceMappingURL=" + path.basename(params.targetFileName) + ".map\n";
writer.write(JSON.stringify({
Success: true,
SourceFileName: params.sourceFileName,
TargetFileName: params.targetFileName,
MapFileName: params.mapFileName,
Remarks: "Successful!",
Content: js,
Map: JSON.stringify(map)
}));
writer.end();
} catch (error) {
var regex = xRegex.exec(error, xRegex(".*:.\\d*:.\\d*: error: (?(?.*)(\\n*.*)*)", 'gi'));
writer.write(JSON.stringify({
Success: false,
SourceFileName: params.sourceFileName,
TargetFileName: params.targetFileName,
MapFileName: params.mapFileName,
Remarks: "IcedCoffeeScript: An error has occured while processing your request.",
Details: error.message,
Errors: [{
Line: error.location.first_line,
Column: error.location.first_column,
Message: "IcedCoffeeScript: " + regex.message,
FileName: error.filename,
FullMessage: "IcedCoffeeScript: " + regex.fullMessage
}]
}));
writer.end();
var js = compiled.js;
if (params.sourceMapURL !== undefined)
js += "\n//# sourceMappingURL=" + path.basename(params.targetFileName) + ".map\n";
writer.write(JSON.stringify({
Success: true,
SourceFileName: params.sourceFileName,
TargetFileName: params.targetFileName,
MapFileName: params.mapFileName,
Remarks: "Successful!",
Content: js,
Map: JSON.stringify(map)
}));
writer.end();
} catch (error) {
var regex = xRegex.exec(error, xRegex(".*:.\\d*:.\\d*: error: (?(?.*)(\\n*.*)*)", 'gi'));
writer.write(JSON.stringify({
Success: false,
SourceFileName: params.sourceFileName,
TargetFileName: params.targetFileName,
MapFileName: params.mapFileName,
Remarks: "CoffeeScript: An error has occured while processing your request.",
Details: regex.message,
Errors: [{
Line: error.location.first_line,
Column: error.location.first_column,
Message: "CoffeeScript: " + regex.message,
FileName: error.filename,
FullMessage: "CoffeeScript: " + regex.fullMessage
}]
}));
writer.end();
this._send('MDTM ' + path, function(err, text, code) {
if (code === 502) {
return self.list(path, function(err, list) {
if (err)
return cb(err);
if (list.length === 1)
cb(undefined, list[0].date);
else
cb(new Error('File not found'));
}, true);
} else if (err)
return cb(err);
var val = XRegExp.exec(text, REX_TIMEVAL), ret;
if (!val)
return cb(new Error('Invalid date/time format from server'));
ret = new Date(val.year + '-' + val.month + '-' + val.date + 'T' + val.hour
+ ':' + val.minute + ':' + val.second);
cb(undefined, ret);
});
};
this._send('MDTM ' + path, function (err, text, code) {
if (code === 502) {
return self.list(path, function (err, list) {
if (err)
return cb(err);
if (list.length === 1)
cb(undefined, list[0].date);
else
cb(new Error('File not found'));
}, true);
} else if (err)
return cb(err);
var val = XRegExp.exec(text, REX_TIMEVAL), ret;
if (!val)
return cb(new Error('Invalid date/time format from server'));
ret = new Date(val.year + '-' + val.month + '-' + val.date + 'T' + val.hour
+ ':' + val.minute + ':' + val.second);
cb(undefined, ret);
});
};