[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:
parent
7cc86ad4c0
commit
e404450e1a
3 changed files with 3 additions and 6 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
// helpers
|
// helpers
|
||||||
import { API_BASE_URL } from "@/helpers/common.helper";
|
import { API_BASE_URL } from "@/helpers/common.helper";
|
||||||
import { checkURLValidity } from "@/helpers/string.helper";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description combine the file path with the base URL
|
* @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 => {
|
export const getFileURL = (path: string): string | undefined => {
|
||||||
if (!path) return undefined;
|
if (!path) return undefined;
|
||||||
const isValidURL = checkURLValidity(path);
|
const isValidURL = path.startsWith("http");
|
||||||
if (isValidURL) return path;
|
if (isValidURL) return path;
|
||||||
return `${API_BASE_URL}${path}`;
|
return `${API_BASE_URL}${path}`;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
import { TFileMetaDataLite, TFileSignedURLResponse } from "@plane/types";
|
import { TFileMetaDataLite, TFileSignedURLResponse } from "@plane/types";
|
||||||
// helpers
|
// helpers
|
||||||
import { API_BASE_URL } from "@/helpers/common.helper";
|
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
|
* @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 => {
|
export const getFileURL = (path: string): string | undefined => {
|
||||||
if (!path) return undefined;
|
if (!path) return undefined;
|
||||||
const isValidURL = checkURLValidity(path);
|
const isValidURL = path.startsWith("http");
|
||||||
if (isValidURL) return path;
|
if (isValidURL) return path;
|
||||||
return `${API_BASE_URL}${path}`;
|
return `${API_BASE_URL}${path}`;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
import { TFileMetaDataLite, TFileSignedURLResponse } from "@plane/types";
|
import { TFileMetaDataLite, TFileSignedURLResponse } from "@plane/types";
|
||||||
// helpers
|
// helpers
|
||||||
import { API_BASE_URL } from "@/helpers/common.helper";
|
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
|
* @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 => {
|
export const getFileURL = (path: string): string | undefined => {
|
||||||
if (!path) return undefined;
|
if (!path) return undefined;
|
||||||
const isValidURL = checkURLValidity(path);
|
const isValidURL = path.startsWith("http");
|
||||||
if (isValidURL) return path;
|
if (isValidURL) return path;
|
||||||
return `${API_BASE_URL}${path}`;
|
return `${API_BASE_URL}${path}`;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue