mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
added "buildURL" helper function
This commit is contained in:
@@ -26,3 +26,14 @@ export const getFromQuery = ({
|
||||
return defaultValue;
|
||||
}
|
||||
};
|
||||
|
||||
export const buildURL = (baseUrl: string, relativePath: string): string => {
|
||||
try {
|
||||
new URL(baseUrl);
|
||||
} catch {
|
||||
throw new Error(`Invalid base URL: ${baseUrl}`);
|
||||
}
|
||||
const url = new URL(relativePath, baseUrl);
|
||||
|
||||
return url.toString();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user