Skip to content

Commit 6e1b589

Browse files
committed
fix(settings): enhance ProxyHosts handling and input validation
Signed-off-by: Pavel Pikta <devops@pavelpikta.com> Co-Authored-By: Pavel Pikta <devops@pavelpikta.com>
1 parent 0ec4004 commit 6e1b589

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

web/src/components/Settings/SecondarySettingsComponent.jsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ export default function SecondarySettingsComponent({ settings, inputForm }) {
7272
ProxyHosts,
7373
} = settings || {}
7474

75+
// Local state for ProxyHosts text input
76+
const [proxyHostsText, setProxyHostsText] = useState('')
77+
78+
// Sync proxyHostsText with ProxyHosts when settings change
79+
useEffect(() => {
80+
const textValue = Array.isArray(ProxyHosts) ? ProxyHosts.join(', ') : ProxyHosts || ''
81+
setProxyHostsText(textValue)
82+
}, [ProxyHosts])
83+
7584
// Use useMemo to compute basePath once
7685
const basePath = useMemo(() => {
7786
if (typeof window !== 'undefined') {
@@ -456,7 +465,17 @@ export default function SecondarySettingsComponent({ settings, inputForm }) {
456465
{/* Proxy hosts */}
457466
<TextField
458467
onChange={e => {
459-
const hostsArray = e.target.value.split(',').map(s => s.trim())
468+
setProxyHostsText(e.target.value)
469+
}}
470+
onBlur={e => {
471+
const inputValue = e.target.value.trim()
472+
const hostsArray =
473+
inputValue === ''
474+
? []
475+
: inputValue
476+
.split(',')
477+
.map(s => s.trim())
478+
.filter(s => s !== '')
460479

461480
inputForm({
462481
target: {
@@ -469,7 +488,7 @@ export default function SecondarySettingsComponent({ settings, inputForm }) {
469488
id='ProxyHosts'
470489
label={t('SettingsDialog.ProxyHosts')}
471490
helperText={t('SettingsDialog.ProxyHostsHint')}
472-
value={Array.isArray(ProxyHosts) ? ProxyHosts.join(', ') : ''}
491+
value={proxyHostsText}
473492
type='text'
474493
variant='outlined'
475494
fullWidth

web/src/components/Settings/SettingsDialog.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ export default function SettingsDialog({ handleClose }) {
7878
else sets[id] = Boolean(checked)
7979
} else if (type === 'url' || type === 'text') {
8080
sets[id] = value
81+
} else if (!type && value !== undefined) {
82+
// Fallback for custom handlers that don't provide type (e.g., ProxyHosts array)
83+
sets[id] = value
8184
}
8285
setSettings(sets)
8386
}

0 commit comments

Comments
 (0)