mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00
Safely parse numbers from environment vars
This adds the function parseOptionalInt to help parse numbers from environment variables Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
36e721d4a9
commit
52f6310e91
5 changed files with 23 additions and 8 deletions
|
@ -113,3 +113,10 @@ function transformLoglevelToInt(loglevel: Loglevel): number {
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
export function parseOptionalInt(value?: string): number | undefined {
|
||||
if (value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return parseInt(value);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue