* fix: generate file url function * chore: remove unused imports * chore: replace indexOf logix with startsWith
14 lines
417 B
TypeScript
14 lines
417 B
TypeScript
// helpers
|
|
import { API_BASE_URL } from "@/helpers/common.helper";
|
|
|
|
/**
|
|
* @description combine the file path with the base URL
|
|
* @param {string} path
|
|
* @returns {string} final URL with the base URL
|
|
*/
|
|
export const getFileURL = (path: string): string | undefined => {
|
|
if (!path) return undefined;
|
|
const isValidURL = path.startsWith("http");
|
|
if (isValidURL) return path;
|
|
return `${API_BASE_URL}${path}`;
|
|
};
|