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

Modification to syntax.js parser RegEx to provide better Unicode support #4390

Closed
wants to merge 8 commits into from
15 changes: 10 additions & 5 deletions kahuna/public/js/search/structured-query/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {getLabel, getCollection} from '../../search-query/query-syntax';

// Line too long for eslint, but can't break it down..
/*eslint-disable max-len */
const parserRe = /(-?)(?:(?:([a-zA-Z@><]+):|(#)|(~))(?:([^ "']+)|"([^"]+)"|'([^']+)')|([a-zA-Z0-9]+)|"([^"]*)"|'([^']*)')/g;
//const parserRe = /(-?)(?:(?:([\p{L}@><]+):|(#)|(~))(?:([^ "']+)|"([^"]+)"|'([^']+)')|([\p{L}0-9]+)|"([^"]*)"|'([^']*)')/gu;
const parserRe = /(-?)(?:(?:([\p{L}@><]+):|"([^"]+)":|'([^']+)':|(#)|(~))(?:([^ "']+)|"([^"]+)"|'([^']+)')|([\p{L}0-9]+)|"([^"]*)"|'([^']*)')/gu;
/*eslint-enable max-len */
const falsyValuesToEmptyString = (value) => {
if (!value){
Expand All @@ -23,10 +24,14 @@ export function structureQuery(query) {
}
while ((m = parserRe.exec(query)) !== null) {
const sign = m[1];
const field = m[2];
const symbol = m[3] || m[4];
const value = m[5] || m[6] || m[7];
const text = m[8] || m[9] || m[10];
//const field = m[2];
//const symbol = m[3] || m[4];
//const value = m[5] || m[6] || m[7];
//const text = m[8] || m[9] || m[10];
const field = m[2] || m[3] || m[4];
const symbol = m[5] || m[6];
const value = m[7] || m[8] || m[9];
const text = m[10] || m[11] || m[12];
const key = {
'#': 'label',
'~': 'collection'
Expand Down
Loading