Skip to content

Commit

Permalink
Update Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Feb 11, 2025
1 parent 2c0c072 commit 1d61c72
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,24 @@ parse.unit = es
parse('1 hora 20 minutos', 'm') // 80
```


## Security Note

To avoid issues with long strings in sensitive APIs, limit input length:

```js
const MAX_INPUT_LENGTH = 100;

function safeParse(input) {
if (input.length > MAX_INPUT_LENGTH) {
throw new Error('Input string is too long');
}
return parseDuration(input);
}

safeParse('1hr 20mins'); // => 1 * h + 20 * m
```



<p align="center"><a href="https://github.com/krishnized/license">ॐ</a></p>

0 comments on commit 1d61c72

Please sign in to comment.