Skip to content

Commit

Permalink
chore: replace indexOf logix with startsWith
Browse files Browse the repository at this point in the history
  • Loading branch information
aaryan610 committed Oct 12, 2024
1 parent 26d70f8 commit 70f7ee3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion admin/helpers/file.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
};
2 changes: 1 addition & 1 deletion space/helpers/file.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
};
Expand Down
2 changes: 1 addition & 1 deletion web/helpers/file.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
};
Expand Down

0 comments on commit 70f7ee3

Please sign in to comment.