mirror of
https://github.com/hexastack/hexabot
synced 2025-03-10 14:25:42 +00:00
Update frontend/src/utils/URL.ts
Co-authored-by: Mohamed Marrouchi <marrouchi.mohamed@gmail.com>
This commit is contained in:
parent
daa2e0611f
commit
9f10cb38d4
@ -29,11 +29,11 @@ export const getFromQuery = ({
|
|||||||
|
|
||||||
export const buildURL = (baseUrl: string, relativePath: string): string => {
|
export const buildURL = (baseUrl: string, relativePath: string): string => {
|
||||||
try {
|
try {
|
||||||
new URL(baseUrl);
|
|
||||||
|
const url = new URL(relativePath, baseUrl);
|
||||||
|
|
||||||
|
return url.toString();
|
||||||
} catch {
|
} catch {
|
||||||
throw new Error(`Invalid base URL: ${baseUrl}`);
|
throw new Error(`Invalid base URL: ${baseUrl}`);
|
||||||
}
|
}
|
||||||
const url = new URL(relativePath, baseUrl);
|
|
||||||
|
|
||||||
return url.toString();
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user