Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
matches.forEach(match => {
// @TODO Implement validateMatch as in .NET
let preText = source.substring(0, match.index);
let relativeRegex = RegExpUtility.getMatchEnd(this.config.strictRelativeRegex, preText, true);
if (relativeRegex.success) {
ret.push(new Token(relativeRegex.match.index, match.index + match.length));
}
else {
ret.push(new Token(match.index, match.index + match.length));
}
});
});
this.config.dateRegex.some(regex => {
let offset = 0;
let relativeStr = null;
let match = RegExpUtility.getMatches(regex, trimmedSource).pop();
if (!match) {
match = RegExpUtility.getMatches(regex, this.config.dateTokenPrefix + trimmedSource).pop();
if (match) {
offset = this.config.dateTokenPrefix.length;
relativeStr = match.groups('order').value;
}
}
if (match) {
let relativeRegex = RegExpUtility.getMatchEnd(this.config.strictRelativeRegex, source.substring(0, match.index), true);
let isContainRelative = relativeRegex.success && match.index + match.length === trimmedSource.length;
if ((match.index === offset && match.length === trimmedSource.length) || isContainRelative) {
if (match.index !== offset) {
relativeStr = relativeRegex.match.value;
}
result = this.matchToDate(match, referenceDate, relativeStr);
return true;
}
}
});
return result;