Skip to content

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

remove trailling slash from url

adilson3c71320a885e
diff --git a/backend/src/services/app-connection/ovh/ovh-connection-fns.ts b/backend/src/services/app-connection/ovh/ovh-connection-fns.ts
index 0e1545e3ef..37dc972a58 100644
--- a/backend/src/services/app-connection/ovh/ovh-connection-fns.ts
+++ b/backend/src/services/app-connection/ovh/ovh-connection-fns.ts
@@ -2,6 +2,7 @@ import https from "https";
import { request } from "@app/lib/config/request";
import { BadRequestError } from "@app/lib/errors";
+import { removeTrailingSlash } from "@app/lib/fn";
import { validateSsrfUrl } from "@app/lib/validator";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
@@ -25,8 +26,28 @@ export const getOvhHttpsAgent = (connection: Pick<TOvhConnection, "credentials">
});
};
+const normalizeOvhOkmsDomain = (okmsDomain: string) => {
+ const normalized = removeTrailingSlash(okmsDomain.trim());
+
+ let url: URL;
+ try {
+ url = new URL(normalized);
+ } catch {
+ throw new BadRequestError({
+ message: "OKMS domain must be a valid URL "
+ });
+ }
+
+ if (url.protocol !== "https:") {
+ throw new BadRequestError({ message: "OKMS domain must use https" });
+ }
+
+ return normalized;
+};
+
export const validateOvhConnectionCredentials = async (config: TOvhConnectionConfig) => {
- const { okmsDomain, okmsId } = config.credentials;
+ const okmsDomain = normalizeOvhOkmsDomain(config.credentials.okmsDomain);
+ const { okmsId } = config.credentials;
await validateSsrfUrl(okmsDomain);
@@ -44,5 +65,8 @@ export const validateOvhConnectionCredentials = async (config: TOvhConnectionCon
});
}
- return config.credentials;
+ return {
+ ...config.credentials,
+ okmsDomain
+ };
};
diff --git a/backend/src/services/app-connection/ovh/ovh-connection-schemas.ts b/backend/src/services/app-connection/ovh/ovh-connection-schemas.ts
index 38e52c000c..00974896e5 100644
--- a/backend/src/services/app-connection/ovh/ovh-connection-schemas.ts
+++ b/backend/src/services/app-connection/ovh/ovh-connection-schemas.ts
@@ -19,7 +19,6 @@ export const OvhConnectionCertificateCredentialsSchema = z.object({
.trim()
.min(1, "OKMS domain required")
.url("OKMS domain must be a valid URL (e.g. https://example.com)")
- .refine((val) => new URL(val).protocol === "https:", { message: "OKMS domain must use https" })
.describe(AppConnections.CREDENTIALS.OVH.okmsDomain),
okmsId: z.string().trim().min(1, "OKMS ID required").describe(AppConnections.CREDENTIALS.OVH.okmsId)
});