Skip to content

Commit 7469356

Browse files
authored
fix: utils.classify may causes '"replace" is not a function' exception (#1660)
1 parent 7c19896 commit 7469356

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/shared-utils/src/util.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ function cached (fn) {
2121

2222
const classifyRE = /(?:^|[-_/])(\w)/g
2323
export const classify = cached((str) => {
24-
return str && str.replace(classifyRE, toUpper)
24+
// fix: str.replace may causes '"replace" is not a function' exception.
25+
// This bug may causes the UI 'Component Filter' to not work properly
26+
// e.g. The type of 'str' is Number.
27+
// So need cover 'str' to String.
28+
return str && ('' + str).replace(classifyRE, toUpper)
2529
})
2630

2731
const camelizeRE = /-(\w)/g

0 commit comments

Comments
 (0)