mirror of
https://github.com/usebruno/bruno.git
synced 2025-06-25 06:21:57 +02:00
fix: prevent non-numerical or negative timeouts
This commit is contained in:
parent
a9459bc236
commit
ddd479ed45
@ -25,8 +25,9 @@ const General = ({ close }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleTimeoutChange = (value) => {
|
const handleTimeoutChange = (value) => {
|
||||||
const validTimeout = isNaN(Number(value)) ? timeout : Number(value);
|
if (/^[0-9]\d*$/.test(value) || value === '') {
|
||||||
setTimeout(validTimeout);
|
setTimeout(value);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -47,13 +48,14 @@ const General = ({ close }) => {
|
|||||||
<label className="block font-medium select-none">Request Timeout (in ms)</label>
|
<label className="block font-medium select-none">Request Timeout (in ms)</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="block textbox mt-2 w-1/4"
|
className="block textbox mt-2 w-1/3"
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
autoCorrect="off"
|
autoCorrect="off"
|
||||||
autoCapitalize="off"
|
autoCapitalize="off"
|
||||||
spellCheck="false"
|
spellCheck="false"
|
||||||
onChange={(e) => handleTimeoutChange(e.target.value)}
|
onChange={(e) => handleTimeoutChange(e.target.value)}
|
||||||
defaultValue={timeout === 0 ? '' : timeout}
|
defaultValue={timeout === 0 ? '' : timeout}
|
||||||
|
value={timeout}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user