escape name RegExp properly, remove useless file
This commit is contained in:
parent
abd40ee44a
commit
3d82c49a84
|
@ -298,6 +298,15 @@ export function setBrightness(hex, dark: boolean = false) {
|
||||||
return `#${r.toString(16)}${g.toString(16)}${b.toString(16)}`;
|
return `#${r.toString(16)}${g.toString(16)}${b.toString(16)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* escape string for use in regexp
|
||||||
|
* @param string input string
|
||||||
|
* @return escaped string
|
||||||
|
*/
|
||||||
|
function escapeRegExp(string) {
|
||||||
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create RegExp to search for ping in chat messages
|
* create RegExp to search for ping in chat messages
|
||||||
* @param name name
|
* @param name name
|
||||||
|
@ -305,5 +314,5 @@ export function setBrightness(hex, dark: boolean = false) {
|
||||||
*/
|
*/
|
||||||
export function createNameRegExp(name: string) {
|
export function createNameRegExp(name: string) {
|
||||||
if (!name) return null;
|
if (!name) return null;
|
||||||
return new RegExp(`(^|\\s+)(@${name})(\\s+|$)`, 'g');
|
return new RegExp(`(^|\\s+)(@${escapeRegExp(name)})(\\s+|$)`, 'g');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
/**
|
|
||||||
* @flow
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* http://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript
|
|
||||||
* @param a
|
|
||||||
* @param b
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
function cellsEquals(a: Cell, b: Cell): boolean {
|
|
||||||
if (a === b) return true;
|
|
||||||
if (a === null || b === null) return false;
|
|
||||||
|
|
||||||
return (a[0] === b[0]) && (a[1] === b[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default cellsEquals;
|
|
Loading…
Reference in New Issue
Block a user