Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
bda7c39e
Unverified
Commit
bda7c39e
authored
Mar 21, 2026
by
Wesley Liddick
Committed by
GitHub
Mar 21, 2026
Browse files
Merge pull request #1196 from Eilen6316/fix/settings-form-url-validation
fix: prevent silent save failure in admin settings form
parents
3583283e
73eb7318
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/src/views/admin/SettingsView.vue
View file @
bda7c39e
...
...
@@ -7,7 +7,7 @@
</div>
<!-- Settings Form -->
<form
v-else
@
submit.prevent=
"saveSettings"
class=
"space-y-6"
>
<form
v-else
@
submit.prevent=
"saveSettings"
class=
"space-y-6"
novalidate
>
<!-- Tab Navigation -->
<div
class=
"sticky top-0 z-10 overflow-x-auto settings-tabs-scroll"
>
<nav
class=
"settings-tabs"
>
...
...
@@ -2198,6 +2198,35 @@ async function saveSettings() {
return
}
// Validate URL fields — novalidate disables browser-native checks, so we validate here
const
isValidHttpUrl
=
(
url
:
string
):
boolean
=>
{
if
(
!
url
)
return
true
try
{
const
u
=
new
URL
(
url
)
return
u
.
protocol
===
'
http:
'
||
u
.
protocol
===
'
https:
'
}
catch
{
return
false
}
}
// Optional URL fields: auto-clear invalid values so they don't cause backend 400 errors
if
(
!
isValidHttpUrl
(
form
.
frontend_url
))
form
.
frontend_url
=
''
if
(
!
isValidHttpUrl
(
form
.
doc_url
))
form
.
doc_url
=
''
// Purchase URL: required when enabled; auto-clear when disabled to avoid backend rejection
if
(
form
.
purchase_subscription_enabled
)
{
if
(
!
form
.
purchase_subscription_url
)
{
appStore
.
showError
(
t
(
'
admin.settings.purchase.url
'
)
+
'
: URL is required when purchase is enabled
'
)
saving
.
value
=
false
return
}
if
(
!
isValidHttpUrl
(
form
.
purchase_subscription_url
))
{
appStore
.
showError
(
t
(
'
admin.settings.purchase.url
'
)
+
'
: must be an absolute http(s) URL (e.g. https://example.com)
'
)
saving
.
value
=
false
return
}
}
else
if
(
!
isValidHttpUrl
(
form
.
purchase_subscription_url
))
{
form
.
purchase_subscription_url
=
''
}
const
payload
:
UpdateSettingsRequest
=
{
registration_enabled
:
form
.
registration_enabled
,
email_verify_enabled
:
form
.
email_verify_enabled
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment