mirror of
https://github.com/hexastack/hexabot
synced 2024-11-24 13:05:15 +00:00
Merge pull request #117 from devamitranjan/FIX#114
feat(frontend): added fix for the base url
This commit is contained in:
commit
28313e1cf7
@ -1,9 +1,14 @@
|
|||||||
export const buildURL = (baseUrl: string, relativePath: string): string => {
|
export const buildURL = (baseUrl: string, relativePath: string): string => {
|
||||||
try {
|
try {
|
||||||
const url = new URL(relativePath, baseUrl);
|
return new URL(relativePath).toString();
|
||||||
|
|
||||||
return url.toString();
|
|
||||||
} catch {
|
} catch {
|
||||||
throw new Error(`Invalid base URL: ${baseUrl}`);
|
try {
|
||||||
|
return new URL(
|
||||||
|
relativePath.replace(/^\//, ''),
|
||||||
|
baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`,
|
||||||
|
).toString();
|
||||||
|
} catch {
|
||||||
|
throw new Error(`Invalid base URL: ${baseUrl}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -28,11 +28,16 @@ export const getFromQuery = ({
|
|||||||
|
|
||||||
export const buildURL = (baseUrl: string, relativePath: string): string => {
|
export const buildURL = (baseUrl: string, relativePath: string): string => {
|
||||||
try {
|
try {
|
||||||
const url = new URL(relativePath, baseUrl);
|
return new URL(relativePath).toString();
|
||||||
|
|
||||||
return url.toString();
|
|
||||||
} catch {
|
} catch {
|
||||||
throw new Error(`Invalid base URL: ${baseUrl}`);
|
try {
|
||||||
|
return new URL(
|
||||||
|
relativePath.replace(/^\//, ""),
|
||||||
|
baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`,
|
||||||
|
).toString();
|
||||||
|
} catch {
|
||||||
|
throw new Error(`Invalid base URL: ${baseUrl}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user