mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-18 11:36:53 +02:00
23 lines
561 B
TypeScript
23 lines
561 B
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
/**
|
|
* Utility to convert an optional string into a Regex case insensitive and global
|
|
*/
|
|
export function isRegexpStringMatch(
|
|
regexAsString?: string,
|
|
valueToTest?: string,
|
|
): boolean {
|
|
if (
|
|
typeof regexAsString === 'undefined' ||
|
|
typeof valueToTest === 'undefined'
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
return new RegExp(regexAsString, 'gi').test(valueToTest);
|
|
}
|