fix(mail regex): removed global flag

This commit is contained in:
DecDuck
2024-12-27 13:14:29 +11:00
parent 61d88c3091
commit 43e32b44a2
3 changed files with 3 additions and 4 deletions

View File

@ -382,7 +382,6 @@ import {
import type { Invitation } from "@prisma/client"; import type { Invitation } from "@prisma/client";
import moment from "moment"; import moment from "moment";
import type { SerializeObject } from "nitropack"; import type { SerializeObject } from "nitropack";
import LoadingButton from "~/components/LoadingButton.vue";
definePageMeta({ definePageMeta({
layout: "admin", layout: "admin",
@ -434,7 +433,7 @@ const email = computed({
_email.value = v; _email.value = v;
}, },
}); });
const mailRegex = /^\S+@\S+\.\S+$/g; const mailRegex = /^\S+@\S+\.\S+$/;
const validEmail = computed(() => const validEmail = computed(() =>
_email.value === undefined ? true : mailRegex.test(email.value as string) _email.value === undefined ? true : mailRegex.test(email.value as string)
); );

View File

@ -208,7 +208,7 @@ const username = ref(invitation.data.value?.username);
const password = ref(""); const password = ref("");
const confirmPassword = ref(undefined); const confirmPassword = ref(undefined);
const mailRegex = /^\S+@\S+\.\S+$/g; const mailRegex = /^\S+@\S+\.\S+$/;
const validEmail = computed(() => mailRegex.test(email.value ?? "")); const validEmail = computed(() => mailRegex.test(email.value ?? ""));
const validUsername = computed( const validUsername = computed(
() => () =>

View File

@ -5,7 +5,7 @@ import { v4 as uuidv4 } from "uuid";
import * as jdenticon from "jdenticon"; import * as jdenticon from "jdenticon";
// Only really a simple test, in case people mistype their emails // Only really a simple test, in case people mistype their emails
const mailRegex = /^\S+@\S+\.\S+$/g; const mailRegex = /^\S+@\S+\.\S+$/;
export default defineEventHandler(async (h3) => { export default defineEventHandler(async (h3) => {
const body = await readBody(h3); const body = await readBody(h3);