From 70f7ee350cb48f707308024bf6c784f7c13039eb Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal Date: Sat, 12 Oct 2024 23:39:17 +0530 Subject: [PATCH] chore: replace indexOf logix with startsWith --- admin/helpers/file.helper.ts | 2 +- space/helpers/file.helper.ts | 2 +- web/helpers/file.helper.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/helpers/file.helper.ts b/admin/helpers/file.helper.ts index d9ed47dafe..6e1f546360 100644 --- a/admin/helpers/file.helper.ts +++ b/admin/helpers/file.helper.ts @@ -8,7 +8,7 @@ import { API_BASE_URL } from "@/helpers/common.helper"; */ export const getFileURL = (path: string): string | undefined => { if (!path) return undefined; - const isValidURL = path.indexOf("http") === 0; + const isValidURL = path.startsWith("http"); if (isValidURL) return path; return `${API_BASE_URL}${path}`; }; diff --git a/space/helpers/file.helper.ts b/space/helpers/file.helper.ts index 2b2d9a3c47..b149ebc7cf 100644 --- a/space/helpers/file.helper.ts +++ b/space/helpers/file.helper.ts @@ -23,7 +23,7 @@ export const generateFileUploadPayload = (signedURLResponse: TFileSignedURLRespo */ export const getFileURL = (path: string): string | undefined => { if (!path) return undefined; - const isValidURL = path.indexOf("http") === 0; + const isValidURL = path.startsWith("http"); if (isValidURL) return path; return `${API_BASE_URL}${path}`; }; diff --git a/web/helpers/file.helper.ts b/web/helpers/file.helper.ts index fd9a9d2241..a64177a7ab 100644 --- a/web/helpers/file.helper.ts +++ b/web/helpers/file.helper.ts @@ -23,7 +23,7 @@ export const generateFileUploadPayload = (signedURLResponse: TFileSignedURLRespo */ export const getFileURL = (path: string): string | undefined => { if (!path) return undefined; - const isValidURL = path.indexOf("http") === 0; + const isValidURL = path.startsWith("http"); if (isValidURL) return path; return `${API_BASE_URL}${path}`; };