Skip to content

Commit

Permalink
cleanup: Removes JSON array parsing.
Browse files Browse the repository at this point in the history
JSON is a subset of YAML, making it redundant.
  • Loading branch information
tommie committed Jul 25, 2024
1 parent 51b3638 commit 716db4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/index.js

Large diffs are not rendered by default.

12 changes: 2 additions & 10 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,11 @@ export function matchGitArgs(string: string) {
}

/**
* Tries to parse a JSON array, then a YAML array.
* If both fail, it returns an array containing the input value as its only element
* Tries to parse a YAML sequence (which can be a JSON array).
* If it fails, it returns an array containing the input value as its only element.
*/
export function parseInputArray(input: string): string[] {
core.debug(`Parsing input array: ${input}`);
try {
const json = JSON.parse(input);
if (json && Array.isArray(json) && json.every(e => typeof e === 'string')) {
core.debug(`Input parsed as JSON array of length ${json.length}`);
return json;
}
} catch {} // eslint-disable-line no-empty

try {
const yaml = YAML.load(input);
if (yaml && Array.isArray(yaml) && yaml.every(e => typeof e === 'string')) {
Expand Down

0 comments on commit 716db4a

Please sign in to comment.