Support non-ASCII characters in GFM autocomplete

This commit is contained in:
samrose3 2017-01-23 18:30:03 -05:00 committed by Sam Rose
parent 797ca1b15d
commit 80ad1c6299
3 changed files with 20 additions and 3 deletions

View File

@ -83,12 +83,12 @@
_a = decodeURI("%C3%80");
_y = decodeURI("%C3%BF");
regexp = new RegExp("^(?:\\B|[^a-zA-Z0-9_" + atSymbolsWithoutBar + "]|\\s)" + flag + "(?![" + atSymbolsWithBar + "])([A-Za-z" + _a + "-" + _y + "0-9_\'\.\+\-]*)$", 'gi');
regexp = new RegExp("^(?:\\B|[^a-zA-Z0-9_" + atSymbolsWithoutBar + "]|\\s)" + flag + "(?![" + atSymbolsWithBar + "])(([A-Za-z" + _a + "-" + _y + "0-9_\'\.\+\-]|[^\\x00-\\x7a])*)$", 'gi');
match = regexp.exec(subtext);
if (match) {
return match[2] || match[1];
return (match[1] || match[1] === "") ? match[1] : match[2];
} else {
return null;
}

View File

@ -0,0 +1,4 @@
---
title: Support non-ASCII characters in GFM autocomplete
merge_request: 8729
author:

View File

@ -2,7 +2,7 @@ require 'rails_helper'
feature 'GFM autocomplete', feature: true, js: true do
include WaitForAjax
let(:user) { create(:user, username: 'someone.special') }
let(:user) { create(:user, name: '💃speciąl someone💃', username: 'someone.special') }
let(:project) { create(:project) }
let(:label) { create(:label, project: project, title: 'special+') }
let(:issue) { create(:issue, project: project) }
@ -59,6 +59,19 @@ feature 'GFM autocomplete', feature: true, js: true do
expect(find('#at-view-64')).to have_selector('.cur:first-of-type')
end
it 'includes items for assignee dropdowns with non-ASCII characters in name' do
page.within '.timeline-content-form' do
find('#note_note').native.send_keys('')
find('#note_note').native.send_keys("@#{user.name[0...8]}")
end
expect(page).to have_selector('.atwho-container')
wait_for_ajax
expect(find('#at-view-64')).to have_content(user.name)
end
it 'selects the first item for non-assignee dropdowns if a query is entered' do
page.within '.timeline-content-form' do
find('#note_note').native.send_keys('')