Kilu.He 6d0598b101
feat: parse folder collab and display document title/icon/cover (#5222)
* feat: support web document and cypress test

* fix: support blocks

* fix: support table and outline

* fix: update nginx

* fix: support document title, icon, cover

fix: mock test folder
2024-04-30 11:32:26 +08:00

48 lines
1.1 KiB
TypeScript

import { getPlatform } from '@/utils/platform';
import validator from 'validator';
export const downloadPage = 'https://appflowy.io/download';
export const openAppFlowySchema = 'appflowy-flutter://';
export function isValidUrl(input: string) {
return validator.isURL(input, { require_protocol: true, require_host: false });
}
// Process the URL to make sure it's a valid URL
// If it's not a valid URL(eg: 'appflowy.io' or '192.168.1.2'), we'll add 'https://' to the URL
export function processUrl(input: string) {
let processedUrl = input;
if (isValidUrl(input)) {
return processedUrl;
}
const domain = input.split('/')[0];
if (validator.isIP(domain) || validator.isFQDN(domain)) {
processedUrl = `https://${input}`;
if (isValidUrl(processedUrl)) {
return processedUrl;
}
}
return;
}
export async function openUrl(url: string, target: string = '_current') {
const platform = getPlatform();
const newUrl = processUrl(url);
if (!newUrl) return;
if (platform.isTauri) {
const { open } = await import('@tauri-apps/api/shell');
await open(newUrl);
return;
}
window.open(newUrl, target);
}