Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue with having usernames with periods or dashes #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixed issue with having usernames with periods or dashes #26

wants to merge 1 commit into from

Conversation

bigfetz
Copy link

@bigfetz bigfetz commented May 25, 2014

No description provided.

@npostma
Copy link

npostma commented Oct 25, 2022

Project seems quite dead, but is stil is a fine plugin for basic usage. I had the dot issue too, but this did not fix it for me. I've changed my matched code to:

_matcher = function (itemProps) {
                    let i;

                    if (settings.emptyQuery) {
                        const q = (this.query.toLowerCase());
                        const caratPos = this.$element[0].selectionStart;
                        const lastChar = q.slice(caratPos-1,caratPos);
                        const beforeLastChar = q.slice(caratPos-2,caratPos-1);

                        if((!beforeLastChar || beforeLastChar.match(new RegExp('[^\\w]'))) && lastChar==settings.delimiter){
                            return true;
                        } else if (lastChar == ' ') {
                            return false;
                        }
                    }

                    for (i in settings.queryBy) {
                        if (itemProps[settings.queryBy[i]]) {
                            const item = itemProps[settings.queryBy[i]].toLowerCase();
                            const regExp = new RegExp('([^\\w]|^)' + settings.delimiter + '[\\w\\.\\-]*', "g");
                            const usernames = (this.query.toLowerCase()).match(regExp);

                            let j;
                            if (!!usernames) {
                                for (j = 0; j < usernames.length; j++) {
                                    const username = (usernames[j].trim().substring(1)).toLowerCase();
                                    const re = new RegExp(settings.delimiter + item, "g");
                                    const used = ((this.query.toLowerCase()).match(re));

                                    if (item.indexOf(username) != -1 && used === null) {
                                        return true;
                                    }
                                }
                            }
                        }
                    }
                },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants