mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-11 02:22:48 +00:00
Prevent trailing slash in sso proxy base url input (#16244)
This commit is contained in:
@@ -95,4 +95,38 @@ describe("SSOModals", () => {
|
||||
expect(getByText("URL must start with http:// or https://")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("should automatically remove trailing slash from the proxy base url", async () => {
|
||||
const TestWrapper = () => {
|
||||
const [form] = Form.useForm();
|
||||
return (
|
||||
<SSOModals
|
||||
isAddSSOModalVisible={true}
|
||||
isInstructionsModalVisible={false}
|
||||
handleAddSSOOk={() => {}}
|
||||
handleAddSSOCancel={() => {}}
|
||||
handleShowInstructions={() => {}}
|
||||
handleInstructionsOk={() => {}}
|
||||
handleInstructionsCancel={() => {}}
|
||||
form={form}
|
||||
accessToken={null}
|
||||
ssoConfigured={false}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const { getByLabelText, container } = render(<TestWrapper />);
|
||||
|
||||
// Fill in the proxy base url with a trailing slash
|
||||
const urlInput = getByLabelText("PROXY BASE URL") as HTMLInputElement;
|
||||
fireEvent.change(urlInput, { target: { value: "https://example.com/" } });
|
||||
|
||||
// Trigger blur to ensure normalization is applied
|
||||
fireEvent.blur(urlInput);
|
||||
|
||||
// Check that the trailing slash was removed by the normalize function
|
||||
await waitFor(() => {
|
||||
expect(urlInput.value).toBe("https://example.com");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -309,16 +309,20 @@ const SSOModals: React.FC<SSOModalsProps> = ({
|
||||
<Form.Item
|
||||
label="PROXY BASE URL"
|
||||
name="proxy_base_url"
|
||||
normalize={(value) => value?.trim()}
|
||||
normalize={(value) => value?.trim().replace(/\/+$/, "")}
|
||||
rules={[
|
||||
{ required: true, message: "Please enter the proxy base url" },
|
||||
{
|
||||
pattern: /^https?:\/\/.+/,
|
||||
message: "URL must start with http:// or https://",
|
||||
},
|
||||
{
|
||||
pattern: /^https?:\/\/[^\s]+[^\/]$/,
|
||||
message: "URL must not end with a trailing slash",
|
||||
},
|
||||
]}
|
||||
>
|
||||
<TextInput />
|
||||
<TextInput placeholder="https://example.com" />
|
||||
</Form.Item>
|
||||
</>
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user