Skip to content

Commit 5e8f679

Browse files
authored
Merge pull request #38 from crazy-max/util-quote
util: handle quote opt with the same api for input list
2 parents cb91211 + f288f4f commit 5e8f679

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

__tests__/util.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,15 @@ describe('getInputList', () => {
7979
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
8080
});
8181

82+
it('do not escape surrounding quotes', async () => {
83+
setInput('driver-opts', `"env.no_proxy=localhost,127.0.0.1,.mydomain"`);
84+
const res = Util.getInputList('driver-opts', {ignoreComma: true, quote: false});
85+
expect(res).toEqual(['"env.no_proxy=localhost,127.0.0.1,.mydomain"']);
86+
});
87+
8288
it('escape surrounding quotes', async () => {
8389
setInput('platforms', 'linux/amd64\n"linux/arm64,linux/arm/v7"');
84-
const res = Util.getInputList('platforms', {escapeQuotes: true});
90+
const res = Util.getInputList('platforms');
8591
expect(res).toEqual(['linux/amd64', 'linux/arm64', 'linux/arm/v7']);
8692
});
8793

src/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {parse} from 'csv-parse/sync';
1919

2020
export interface InputListOpts {
2121
ignoreComma?: boolean;
22-
escapeQuotes?: boolean;
22+
quote?: string | boolean | Buffer | null;
2323
}
2424

2525
export class Util {
@@ -37,7 +37,7 @@ export class Util {
3737
comment: '#',
3838
relaxColumnCount: true,
3939
skipEmptyLines: true,
40-
quote: opts?.escapeQuotes ?? `"`
40+
quote: opts?.quote
4141
});
4242

4343
for (const record of records as Array<string[]>) {

0 commit comments

Comments
 (0)