-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17238 from ElectronicBlueberry/form-data-extensio…
…n-view Add accepted extensions to form data input
- Loading branch information
Showing
5 changed files
with
190 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Converts an array of strings to a list, ending with "or" | ||
* | ||
* @example | ||
* // returns the string "a, b or c" | ||
* orList(["a", "b", "c"]); | ||
* @param items array of strings to join | ||
* @returns human readable comma + or separated list | ||
*/ | ||
export function orList(items: string[]): string { | ||
if (items.length === 0) { | ||
return ""; | ||
} else if (items.length === 1) { | ||
return items[0] as string; | ||
} | ||
|
||
return items | ||
.reverse() | ||
.flatMap((item, index) => { | ||
if (index === 0) { | ||
return [item, " or "]; | ||
} else if (index !== 1) { | ||
return [", ", item]; | ||
} else { | ||
return [item]; | ||
} | ||
}) | ||
.reverse() | ||
.join(""); | ||
} |