Skip to content

Commit 0187f99

Browse files
authored
chore(runtime-core): add isRegExp to check RegExp (#6041)
1 parent c513126 commit 0187f99

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/runtime-core/src/components/KeepAlive.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
import {
2727
isString,
2828
isArray,
29+
isRegExp,
2930
ShapeFlags,
3031
remove,
3132
invokeArrayFns
@@ -350,7 +351,7 @@ function matches(pattern: MatchPattern, name: string): boolean {
350351
return pattern.some((p: string | RegExp) => matches(p, name))
351352
} else if (isString(pattern)) {
352353
return pattern.split(',').includes(name)
353-
} else if (pattern.test) {
354+
} else if (isRegExp(pattern)) {
354355
return pattern.test(name)
355356
}
356357
/* istanbul ignore next */

packages/shared/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export const isSet = (val: unknown): val is Set<any> =>
5454

5555
export const isDate = (val: unknown): val is Date =>
5656
toTypeString(val) === '[object Date]'
57+
export const isRegExp = (val: unknown): val is RegExp =>
58+
toTypeString(val) === '[object RegExp]'
5759
export const isFunction = (val: unknown): val is Function =>
5860
typeof val === 'function'
5961
export const isString = (val: unknown): val is string => typeof val === 'string'

0 commit comments

Comments
 (0)