debug: remove hacky placeholder logic

@visionmedia pointed out that it is not necessary, which is
good because it was very hacky.
This commit is contained in:
Nathan Rajlich 2014-05-31 18:57:30 -07:00
parent b38496e03b
commit 652feca774

View File

@ -56,9 +56,8 @@ function debug(namespace) {
// apply any `formatters` transformations
var index = 0;
args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
// replace "%%" with a placeholder value for now.
// we restore it after doing the formatters parsing.
if (match === '%%') return '68ddd49c85cb46fc8c';
// if we encounter an escaped % then don't increase the array index
if (match === '%%') return match;
index++;
var formatter = exports.formatters[format];
if ('function' === typeof formatter) {
@ -70,7 +69,7 @@ function debug(namespace) {
index--;
}
return match;
}).replace(/68ddd49c85cb46fc8c/g, '%%');
});
exports.log.apply(enabled, args);
}