mirror of
https://github.com/hexastack/hexabot
synced 2025-01-22 10:35:37 +00:00
Merge pull request #27 from kartik1112/main
[ISSUE] #19 Fix urls (trailing or missing slashes)
This commit is contained in:
commit
35b911d2d5
@ -51,6 +51,7 @@ import {
|
||||
import { INlpSampleEntity } from "@/types/nlp-sample_entity.types";
|
||||
import { PermissionAction } from "@/types/permission.types";
|
||||
import { getDateTimeFormatter } from "@/utils/date";
|
||||
import { buildURL } from "@/utils/URL";
|
||||
|
||||
import { NlpImportDialog } from "../NlpImportDialog";
|
||||
import { NlpSampleDialog } from "../NlpSampleDialog";
|
||||
@ -285,9 +286,10 @@ export default function NlpSample() {
|
||||
) ? (
|
||||
<Button
|
||||
variant="contained"
|
||||
href={`${publicRuntimeConfig.apiUrl}/nlpsample/export${
|
||||
dataset ? `?type=${dataset}` : ""
|
||||
}`}
|
||||
href={buildURL(
|
||||
publicRuntimeConfig.apiUrl,
|
||||
`nlpsample/export${dataset ? `?type=${dataset}` : ""}`,
|
||||
)}
|
||||
startIcon={<DownloadIcon />}
|
||||
>
|
||||
{t("button.export")}
|
||||
|
@ -26,3 +26,14 @@ export const getFromQuery = ({
|
||||
return defaultValue;
|
||||
}
|
||||
};
|
||||
|
||||
export const buildURL = (baseUrl: string, relativePath: string): string => {
|
||||
try {
|
||||
|
||||
const url = new URL(relativePath, baseUrl);
|
||||
|
||||
return url.toString();
|
||||
} catch {
|
||||
throw new Error(`Invalid base URL: ${baseUrl}`);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user