mirror of
https://github.com/hexastack/hexabot
synced 2024-11-24 13:05:15 +00:00
feat(frontend): added fix for base url in api side
This commit is contained in:
parent
2871fb432c
commit
008257db64
@ -1,6 +1,10 @@
|
|||||||
export const buildURL = (baseUrl: string, relativePath: string): string => {
|
export const buildURL = (baseUrl: string, relativePath: string): string => {
|
||||||
try {
|
try {
|
||||||
const url = new URL(relativePath, baseUrl);
|
const normalizedBaseUrl = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
|
||||||
|
const normalizedRelativePath = relativePath.startsWith('/')
|
||||||
|
? relativePath.slice(1)
|
||||||
|
: relativePath;
|
||||||
|
const url = new URL(normalizedRelativePath, normalizedBaseUrl);
|
||||||
|
|
||||||
return url.toString();
|
return url.toString();
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user