Skip to content

Commit 1d61c72

Browse files
committed
Update Readme.md
1 parent 2c0c072 commit 1d61c72

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Readme.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,24 @@ parse.unit = es
6262
parse('1 hora 20 minutos', 'm') // 80
6363
```
6464

65+
66+
## Security Note
67+
68+
To avoid issues with long strings in sensitive APIs, limit input length:
69+
70+
```js
71+
const MAX_INPUT_LENGTH = 100;
72+
73+
function safeParse(input) {
74+
if (input.length > MAX_INPUT_LENGTH) {
75+
throw new Error('Input string is too long');
76+
}
77+
return parseDuration(input);
78+
}
79+
80+
safeParse('1hr 20mins'); // => 1 * h + 20 * m
81+
```
82+
83+
84+
6585
<p align="center"><a href="https://github.com/krishnized/license">ॐ</a></p>

0 commit comments

Comments
 (0)