mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-19 04:25:32 +00:00
14 lines
548 B
JavaScript
14 lines
548 B
JavaScript
/**
|
|
* Ensures the given rule name is appended to the provided string.
|
|
*
|
|
* If the string does not already end with the rule name in parentheses, the rule name is appended in parentheses.
|
|
*
|
|
* @param {string} string - The message to which the rule name may be appended
|
|
* @param {string} ruleName - The rule name to append
|
|
*
|
|
* @returns {string} The provided string with the given rule name appended
|
|
*/
|
|
export default function appendRuleName(string, ruleName) {
|
|
return !string.endsWith(`(${ruleName})`) ? `${string} (${ruleName})` : string;
|
|
}
|