chat ui added

This commit is contained in:
n4ze3m
2023-04-15 15:59:10 +05:30
parent 1c7b4c328f
commit 4efc9e05e0
8 changed files with 319 additions and 48 deletions

16
src/utils/icon.ts Normal file
View File

@@ -0,0 +1,16 @@
export const iconUrl = (icon: string, url: string) => {
// check if icon is valid url (http:// or https://)
if (icon.startsWith("http://") || icon.startsWith("https://")) {
return icon;
}
// check if icon is valid url (//)
if (icon.startsWith("//")) {
return `https:${icon}`;
}
const host = new URL(url).hostname;
const protocol = new URL(url).protocol;
return `${protocol}//${host}/${icon}`;
};