Skip to content

Commit fdcfb4e

Browse files
committed
fix: only allow alphanumeric (with dash, underscore) in custom URLs
Signed-off-by: Evan Song <theevansong@gmail.com>
1 parent 4d7b2a0 commit fdcfb4e

File tree

1 file changed

+9
-1
lines changed
  • apps/frontend/src/pages/servers/manage/[id]/options

1 file changed

+9
-1
lines changed

apps/frontend/src/pages/servers/manage/[id]/options/network.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
/>
5454
.modrinth.gg
5555
</div>
56+
<span v-if="!isValidSubdomain" class="text-sm text-rose-400">
57+
Subdomain must be at least 3 characters long and can only contain alphanumeric
58+
characters, dashes, and underscores.
59+
</span>
5660
</div>
5761

5862
<!-- Allocations section -->
@@ -128,7 +132,7 @@
128132
<UiServersPyroLoading v-else />
129133
<div class="absolute bottom-[2.5%] left-[2.5%] z-10 w-[95%]">
130134
<UiServersSaveBanner
131-
v-if="hasUnsavedChanges"
135+
v-if="hasUnsavedChanges && isValidSubdomain"
132136
:server="props.server"
133137
:is-updating="isUpdating"
134138
:save="saveNetwork"
@@ -164,6 +168,8 @@ const newAllocationPort = ref(0);
164168
165169
const hasUnsavedChanges = computed(() => serverSubdomain.value !== data?.value?.net?.domain);
166170
171+
const isValidSubdomain = computed(() => /^[a-zA-Z0-9-_]{3,}$/.test(serverSubdomain.value));
172+
167173
const addNewAllocation = async () => {
168174
if (!newAllocationName.value) return;
169175
@@ -226,6 +232,8 @@ const removeAllocation = async (port: number) => {
226232
};
227233
228234
const saveNetwork = async () => {
235+
if (!isValidSubdomain.value) return;
236+
229237
try {
230238
isUpdating.value = true;
231239
const available = await props.server.network?.checkSubdomainAvailability(serverSubdomain.value);

0 commit comments

Comments
 (0)