fix nick completion on nicks with special chars
This commit is contained in:
parent
2be08c57d2
commit
a1fc84f592
|
@ -8,6 +8,15 @@
|
||||||
var IrcUtils = angular.module('IrcUtils', []);
|
var IrcUtils = angular.module('IrcUtils', []);
|
||||||
|
|
||||||
IrcUtils.service('IrcUtils', [function() {
|
IrcUtils.service('IrcUtils', [function() {
|
||||||
|
/**
|
||||||
|
* Escape a string for usage in a larger regexp
|
||||||
|
* @param str String to escape
|
||||||
|
* @return Escaped string
|
||||||
|
*/
|
||||||
|
var escapeRegExp = function(str) {
|
||||||
|
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a new version of a nick list, sorted by last speaker
|
* Get a new version of a nick list, sorted by last speaker
|
||||||
*
|
*
|
||||||
|
@ -63,7 +72,7 @@ IrcUtils.service('IrcUtils', [function() {
|
||||||
// collect matching nicks
|
// collect matching nicks
|
||||||
for (var i = 0; i < nickList.length; ++i) {
|
for (var i = 0; i < nickList.length; ++i) {
|
||||||
var lcNick = nickList[i].toLowerCase();
|
var lcNick = nickList[i].toLowerCase();
|
||||||
if (lcNick.search(lcIterCandidate) === 0) {
|
if (lcNick.search(escapeRegExp(lcIterCandidate)) === 0) {
|
||||||
matchingNicks.push(nickList[i]);
|
matchingNicks.push(nickList[i]);
|
||||||
if (lcCurrentNick === lcNick) {
|
if (lcCurrentNick === lcNick) {
|
||||||
at = matchingNicks.length - 1;
|
at = matchingNicks.length - 1;
|
||||||
|
@ -149,7 +158,7 @@ IrcUtils.service('IrcUtils', [function() {
|
||||||
m = beforeCaret.match(/^([a-zA-Z0-9_\\\[\]{}^`|-]+)$/);
|
m = beforeCaret.match(/^([a-zA-Z0-9_\\\[\]{}^`|-]+)$/);
|
||||||
if (m) {
|
if (m) {
|
||||||
// try completing
|
// try completing
|
||||||
newNick = _completeSingleNick(m[1], searchNickList);
|
newNick = _completeSingleNick(escapeRegExp(m[1]), searchNickList);
|
||||||
if (newNick === null) {
|
if (newNick === null) {
|
||||||
// no match
|
// no match
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue