browsertrix/frontend/src/utils/string.ts
Ilya Kreymer ea494fa6e6
Merge V1.9.3 changes into main (#1583)
- Fix execution time checking by keeping lastUpdatedTime in db by
@ikreymer in https://github.com/webrecorder/browsertrix-cloud/pull/1573
- disable postcss-lit for var css
- Prevent closing tooltips from closing collection share dialog by
@SuaYoo in https://github.com/webrecorder/browsertrix-cloud/pull/1579
- Fix pending exclusion pagination by @SuaYoo in
https://github.com/webrecorder/browsertrix-cloud/pull/1578
- Fix regex escape in exclusion editor text match by @SuaYoo in
https://github.com/webrecorder/browsertrix-cloud/pull/1577

---------
Co-authored-by: emma <hi@emma.cafe>
Co-authored-by: sua yoo <sua@webrecorder.org>
2024-03-06 15:38:22 -08:00

12 lines
320 B
TypeScript

/**
* Escape string to use as regex
* From https://github.com/tc39/proposal-regex-escaping/blob/main/polyfill.js#L3
*/
export function regexEscape(s: unknown) {
return String(s).replace(/[\\^$*+?.()|[\]{}]/g, "\\$&");
}
export function regexUnescape(s: unknown) {
return String(s).replace(/(\\|\/\.\*)/g, "");
}