Skip to content

Commit

Permalink
Fix replaceUnderscores to handle String type.
Browse files Browse the repository at this point in the history
  • Loading branch information
na9da committed Apr 26, 2024
1 parent b066468 commit c2e4d9a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Core/replaceUnderscores.ts
Expand Up @@ -3,8 +3,10 @@
* @param string The string to replace. If the argument is not a string, does nothing.
* @return The argument with all underscores replaced with spaces. If the argument is not a string, returns the argument unchanged.
*/
function replaceUnderscores(str: string | undefined): typeof str {
return typeof str === "string" ? str.replace(/_/g, " ") : str;
function replaceUnderscores(str: any): typeof str {
return typeof str === "string" || str instanceof String
? str.replace(/_/g, " ")
: str;
}

export default replaceUnderscores;

0 comments on commit c2e4d9a

Please sign in to comment.