[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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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}`;
};

View file

@ -2,7 +2,6 @@
import { TFileMetaDataLite, TFileSignedURLResponse } from "@plane/types";
// helpers
import { API_BASE_URL } from "@/helpers/common.helper";
import { checkURLValidity } from "@/helpers/string.helper";
/**
* @description from the provided signed URL response, generate a payload to be used to upload the file
@ -24,7 +23,7 @@ export const generateFileUploadPayload = (signedURLResponse: TFileSignedURLRespo
*/
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}`;
};

View file

@ -2,7 +2,6 @@
import { TFileMetaDataLite, TFileSignedURLResponse } from "@plane/types";
// helpers
import { API_BASE_URL } from "@/helpers/common.helper";
import { checkURLValidity } from "@/helpers/string.helper";
/**
* @description from the provided signed URL response, generate a payload to be used to upload the file
@ -24,7 +23,7 @@ export const generateFileUploadPayload = (signedURLResponse: TFileSignedURLRespo
*/
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}`;
};