mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-11 23:32:30 +02:00
feat(search-algolia): algolia externalUrl regex to navigate with window.href (#5795)
This commit is contained in:
parent
8c12983a2a
commit
adbc02ea38
9 changed files with 69 additions and 17 deletions
|
@ -93,3 +93,5 @@ export {
|
|||
useIsomorphicLayoutEffect,
|
||||
useDynamicCallback,
|
||||
} from './utils/reactUtils';
|
||||
|
||||
export {isRegexpStringMatch} from './utils/regexpUtils';
|
||||
|
|
23
packages/docusaurus-theme-common/src/utils/regexpUtils.ts
Normal file
23
packages/docusaurus-theme-common/src/utils/regexpUtils.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* 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 sensitive 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue