[WEB-310] regression: generate file url function (#5811)

* fix: generate file url function

* chore: remove unused imports

* chore: replace indexOf logix with startsWith
This commit is contained in:
Aaryan Khandelwal
2024-10-12 23:39:50 +05:30
committed by GitHub
parent 7cc86ad4c0
commit e404450e1a
3 changed files with 3 additions and 6 deletions

View File

@@ -1,6 +1,5 @@
// helpers
import { API_BASE_URL } from "@/helpers/common.helper";
import { checkURLValidity } from "@/helpers/string.helper";
/**
* @description combine the file path with the base URL
@@ -9,7 +8,7 @@ import { checkURLValidity } from "@/helpers/string.helper";
*/
export const getFileURL = (path: string): string | undefined => {
if (!path) return undefined;
const isValidURL = checkURLValidity(path);
const isValidURL = path.startsWith("http");
if (isValidURL) return path;
return `${API_BASE_URL}${path}`;
};