mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-10-11 21:51:56 +00:00
4.0.0-rc2. Add basic custom highlight terms and blocked terms. Change the socket cluster setting because users are users. Open settings in a new window if clicking the chat menu link with ctrl or shift. Hide the Get Bits button in the site navigation. Add an additional socket server.
This commit is contained in:
parent
6b2b734ef9
commit
2a790ad7cd
22 changed files with 669 additions and 48 deletions
|
@ -251,6 +251,65 @@ export const escape_regex = RegExp.escape || function escape_regex(str) {
|
|||
}
|
||||
|
||||
|
||||
const CONTROL_CHARS = '/$^+.()=!|';
|
||||
|
||||
export function glob_to_regex(input) {
|
||||
if ( typeof input !== 'string' )
|
||||
throw new TypeError('input must be a string');
|
||||
|
||||
let output = '',
|
||||
groups = 0;
|
||||
|
||||
for(let i=0, l=input.length; i<l; i++) {
|
||||
const char = input[i];
|
||||
|
||||
if ( CONTROL_CHARS.includes(char) )
|
||||
output += `\\${char}`;
|
||||
|
||||
else if ( char === '?' )
|
||||
output += '.';
|
||||
|
||||
else if ( char === '[' || char === ']' )
|
||||
output += char;
|
||||
|
||||
else if ( char === '{' ) {
|
||||
output += '(?:';
|
||||
groups++;
|
||||
|
||||
} else if ( char === '}' ) {
|
||||
if ( groups > 0 ) {
|
||||
output += ')';
|
||||
groups--;
|
||||
}
|
||||
|
||||
} else if ( char === ',' && groups > 0 )
|
||||
output += '|';
|
||||
|
||||
else if ( char === '*' ) {
|
||||
let count = 1;
|
||||
while(input[i+1] === '*') {
|
||||
count++;
|
||||
i++;
|
||||
}
|
||||
|
||||
if ( count > 1 )
|
||||
output += '.*?';
|
||||
else
|
||||
output += '[^ ]*?';
|
||||
|
||||
} else
|
||||
output += char;
|
||||
}
|
||||
|
||||
while(groups > 0) {
|
||||
output += ')';
|
||||
groups--;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
export class SourcedSet {
|
||||
constructor() {
|
||||
this._cache = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue