Skip to content

Commit

Permalink
fix(utils): append unused format parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mkermani144 committed Jun 29, 2024
1 parent 8b4bebb commit b4e1400
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/utils/lib/logger/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ const formatters = {
const format = (str: string, ...args: any[]) => {
let j = 0;

return str.replace(/%([a-z])/gi, (match, f: keyof typeof formatters) => {
if (formatters[f]) {
return formatters[f](args[j++]);
}
if (f) {
return utilFormat(`%${f}`, args[j++]);
}
return match;
});
const formatted = str.replace(
/%([a-z])/gi,
(match, f: keyof typeof formatters) => {
if (formatters[f]) {
return formatters[f](args[j++]);
}
if (f) {
return utilFormat(`%${f}`, args[j++]);
}
return match;
},
);
return `${formatted} ${args.slice(j).join(' ')}`.trimEnd();
};

export default format;

0 comments on commit b4e1400

Please sign in to comment.