mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add support for quoted csv in ini-values
This commit is contained in:
parent
276480411d
commit
d0f1a91dfd
@ -104,6 +104,17 @@ describe('Utils tests', () => {
|
||||
'b=2',
|
||||
'c=3'
|
||||
]);
|
||||
expect(await utils.CSVArray('\'a=1,2\', "b=3, 4", c=5, d=~e~')).toEqual([
|
||||
'a=1,2',
|
||||
'b=3, 4',
|
||||
'c=5',
|
||||
"d='~e~'"
|
||||
]);
|
||||
expect(await utils.CSVArray('a=\'1,2\', b="3, 4", c=5')).toEqual([
|
||||
'a=1,2',
|
||||
'b=3, 4',
|
||||
'c=5'
|
||||
]);
|
||||
expect(await utils.CSVArray('')).toEqual([]);
|
||||
expect(await utils.CSVArray(' ')).toEqual([]);
|
||||
});
|
||||
|
10
dist/index.js
vendored
10
dist/index.js
vendored
@ -1222,8 +1222,7 @@ async function extensionArray(extension_csv) {
|
||||
return extension
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace('php-', '')
|
||||
.replace('php_', '');
|
||||
.replace(/^php[-_]/, '');
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
@ -1242,9 +1241,12 @@ async function CSVArray(values_csv) {
|
||||
return [];
|
||||
default:
|
||||
return values_csv
|
||||
.split(',')
|
||||
.split(/,(?=(?:(?:[^"']*["']){2})*[^"']*$)/)
|
||||
.map(function (value) {
|
||||
return value.trim();
|
||||
return value
|
||||
.trim()
|
||||
.replace(/^["']|["']$|(?<==)["']/g, '')
|
||||
.replace(/=(.*[?{}|&~![()^]+.*)/, "='$1'");
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
12
src/utils.ts
12
src/utils.ts
@ -209,8 +209,7 @@ export async function extensionArray(
|
||||
return extension
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace('php-', '')
|
||||
.replace('php_', '');
|
||||
.replace(/^php[-_]/, '');
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
@ -229,9 +228,12 @@ export async function CSVArray(values_csv: string): Promise<Array<string>> {
|
||||
return [];
|
||||
default:
|
||||
return values_csv
|
||||
.split(',')
|
||||
.map(function (value: string) {
|
||||
return value.trim();
|
||||
.split(/,(?=(?:(?:[^"']*["']){2})*[^"']*$)/)
|
||||
.map(function (value) {
|
||||
return value
|
||||
.trim()
|
||||
.replace(/^["']|["']$|(?<==)["']/g, '')
|
||||
.replace(/=(.*[?{}|&~![()^]+.*)/, "='$1'");
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user