Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

adjustment: converted remaining salug validation to use slugify

Sheen Capadngan872f8bdad820
diff --git a/frontend/src/components/basic/dialog/AddUpdateEnvironmentDialog.tsx b/frontend/src/components/basic/dialog/AddUpdateEnvironmentDialog.tsx
index f984175466..7d014f80f0 100644
--- a/frontend/src/components/basic/dialog/AddUpdateEnvironmentDialog.tsx
+++ b/frontend/src/components/basic/dialog/AddUpdateEnvironmentDialog.tsx
@@ -17,7 +17,6 @@ type Props = {
};
// TODO: Migrate to better form management and validation. Preferable react-hook-form + yup
-// We should remove this?
/**
* The dialog modal for when the user wants to create a new workspace
* @param {*} param0
diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/UpdateEnvironmentModal.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/UpdateEnvironmentModal.tsx
index 765a6429bd..c6b2152ccb 100644
--- a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/UpdateEnvironmentModal.tsx
+++ b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/UpdateEnvironmentModal.tsx
@@ -1,5 +1,6 @@
import { Controller, useForm } from "react-hook-form";
import { yupResolver } from "@hookform/resolvers/yup";
+import slugify from "@sindresorhus/slugify";
import * as yup from "yup";
import { createNotification } from "@app/components/notifications";
@@ -16,13 +17,19 @@ type Props = {
const schema = yup.object({
name: yup.string().label("Environment Name").required(),
- slug: yup.string().label("Environment Slug").matches(/^[^./]*$/g, { message: "Invalid [.] or [/] not allowed"}).required()
+ slug: yup
+ .string()
+ .label("Environment Slug")
+ .test({
+ test: (slug) => slugify(slug as string) === slug,
+ message: "Slug must be a valid slug"
+ })
+ .required()
});
export type FormData = yup.InferType<typeof schema>;
export const UpdateEnvironmentModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => {
-
const { currentWorkspace } = useWorkspace();
const { mutateAsync, isLoading } = useUpdateWsEnvironment();
const { control, handleSubmit, reset } = useForm<FormData>({
@@ -108,7 +115,11 @@ export const UpdateEnvironmentModal = ({ popUp, handlePopUpClose, handlePopUpTog
Update
</Button>
- <Button onClick={() => handlePopUpClose("updateEnv")} colorSchema="secondary" variant="plain">
+ <Button
+ onClick={() => handlePopUpClose("updateEnv")}
+ colorSchema="secondary"
+ variant="plain"
+ >
Cancel
</Button>
</div>