Skip to content

Commit

Permalink
chore(runtime-core): add isRegExp to check RegExp (vuejs#6041)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfansplz authored and zhangzhonghe committed Apr 12, 2023
1 parent 9d6ccaa commit e418574
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/runtime-core/src/components/KeepAlive.ts
Expand Up @@ -26,6 +26,7 @@ import {
import {
isString,
isArray,
isRegExp,
ShapeFlags,
remove,
invokeArrayFns
Expand Down Expand Up @@ -350,7 +351,7 @@ function matches(pattern: MatchPattern, name: string): boolean {
return pattern.some((p: string | RegExp) => matches(p, name))
} else if (isString(pattern)) {
return pattern.split(',').includes(name)
} else if (pattern.test) {
} else if (isRegExp(pattern)) {
return pattern.test(name)
}
/* istanbul ignore next */
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/index.ts
Expand Up @@ -54,6 +54,8 @@ export const isSet = (val: unknown): val is Set<any> =>

export const isDate = (val: unknown): val is Date =>
toTypeString(val) === '[object Date]'
export const isRegExp = (val: unknown): val is RegExp =>
toTypeString(val) === '[object RegExp]'
export const isFunction = (val: unknown): val is Function =>
typeof val === 'function'
export const isString = (val: unknown): val is string => typeof val === 'string'
Expand Down

0 comments on commit e418574

Please sign in to comment.