diff options
author | Sascha <GlancingMind@outlook.com> | 2021-05-05 12:49:11 +0200 |
---|---|---|
committer | Sascha <GlancingMind@outlook.com> | 2021-05-20 17:07:47 +0200 |
commit | 7446a20db8907acedbd14ddcc6a99de577268c1c (patch) | |
tree | 2fdcffc9bc824d2140b6060113216e0c52182073 /webui/src/__tests__/query.ts | |
parent | 77d36247b3b761e21ef38a764d315cd4d22e7668 (diff) | |
download | git-bug-7446a20db8907acedbd14ddcc6a99de577268c1c.tar.gz |
Do not greedy match quotes
Diffstat (limited to 'webui/src/__tests__/query.ts')
-rw-r--r-- | webui/src/__tests__/query.ts | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/webui/src/__tests__/query.ts b/webui/src/__tests__/query.ts index 69e2f766..97ec75a6 100644 --- a/webui/src/__tests__/query.ts +++ b/webui/src/__tests__/query.ts @@ -17,11 +17,11 @@ it('parses a query with multiple filters', () => { freetext: [''], }); - expect(parse(`label:abc with "quotes" in freetext`)).toEqual({ + expect(parse(`label:abc with "quotes" 'in' freetext`)).toEqual({ label: [`abc`], with: [''], - quotes: [''], - in: [''], + '"quotes"': [''], + "'in'": [''], freetext: [''], }); }); @@ -54,11 +54,44 @@ it('parses a quoted query', () => { expect(parse(`label:"with:quoated:colon"`)).toEqual({ label: [`"with:quoated:colon"`], }); + + expect(parse(`label:'name ends after this ->' quote'`)).toEqual({ + label: [`'name ends after this ->'`], + "quote'": [``], + }); + + expect(parse(`label:"name ends after this ->" quote"`)).toEqual({ + label: [`"name ends after this ->"`], + 'quote"': [``], + }); + + expect(parse(`label:'this ->"<- quote belongs to label name'`)).toEqual({ + label: [`'this ->"<- quote belongs to label name'`], + }); + + expect(parse(`label:"this ->'<- quote belongs to label name"`)).toEqual({ + label: [`"this ->'<- quote belongs to label name"`], + }); + + expect(parse(`label:'names end with'whitespace not with quotes`)).toEqual({ + label: [`'names end with'whitespace`], + not: [``], + with: [``], + quotes: [``], + }); + + expect(parse(`label:"names end with"whitespace not with quotes`)).toEqual({ + label: [`"names end with"whitespace`], + not: [``], + with: [``], + quotes: [``], + }); }); it('should not escape nested quotes', () => { expect(parse(`foo:'do not escape this ->'<- quote'`)).toEqual({ - foo: [`'do not escape this ->'<- quote'`], + foo: [`'do not escape this ->'<-`], + "quote'": [``], }); expect(parse(`foo:'do not escape this ->"<- quote'`)).toEqual({ @@ -66,7 +99,8 @@ it('should not escape nested quotes', () => { }); expect(parse(`foo:"do not escape this ->"<- quote"`)).toEqual({ - foo: [`"do not escape this ->"<- quote"`], + foo: [`"do not escape this ->"<-`], + 'quote"': [``], }); expect(parse(`foo:"do not escape this ->'<- quote"`)).toEqual({ |