Quote ini values with equal sign

This commit is contained in:
Shivam Mathur 2022-12-15 05:27:13 +05:30
parent f20012026f
commit 3407e6019c
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
3 changed files with 7 additions and 2 deletions

View File

@ -109,6 +109,9 @@ describe('Utils tests', () => {
expect( expect(
await utils.CSVArray('a=E_ALL, b=E_ALL & ~ E_ALL, c="E_ALL", d=\'E_ALL\'') await utils.CSVArray('a=E_ALL, b=E_ALL & ~ E_ALL, c="E_ALL", d=\'E_ALL\'')
).toEqual(['a=E_ALL', 'b=E_ALL & ~ E_ALL', 'c=E_ALL', 'd=E_ALL']); ).toEqual(['a=E_ALL', 'b=E_ALL & ~ E_ALL', 'c=E_ALL', 'd=E_ALL']);
expect(
await utils.CSVArray('a="b=c;d=e", b=\'c=d,e\', c="g=h,i=j", d=g=h, a===')
).toEqual(["a='b=c;d=e'", "b='c=d,e'", "c='g=h,i=j'", "d='g=h'", "a='=='"]);
expect(await utils.CSVArray('')).toEqual([]); expect(await utils.CSVArray('')).toEqual([]);
expect(await utils.CSVArray(' ')).toEqual([]); expect(await utils.CSVArray(' ')).toEqual([]);
}); });

3
dist/index.js vendored
View File

@ -1172,7 +1172,8 @@ async function CSVArray(values_csv) {
return value return value
.trim() .trim()
.replace(/^["']|["']$|(?<==)["']/g, '') .replace(/^["']|["']$|(?<==)["']/g, '')
.replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'"); .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'")
.replace(/=(.*?)(=.*)/, "='$1$2'");
}) })
.filter(Boolean); .filter(Boolean);
} }

View File

@ -246,7 +246,8 @@ export async function CSVArray(values_csv: string): Promise<Array<string>> {
return value return value
.trim() .trim()
.replace(/^["']|["']$|(?<==)["']/g, '') .replace(/^["']|["']$|(?<==)["']/g, '')
.replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'"); .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'")
.replace(/=(.*?)(=.*)/, "='$1$2'");
}) })
.filter(Boolean); .filter(Boolean);
} }