Open-source and local-first Slack and Notion alternative that puts you in control of your data
TypeScript chatchat-applicationcrdteditorelectronknowledge-baselocal-firstnotionnotion-alternativerealtime-collaborationself-hostedslacksqliteteam-collaborationwikiyjs
Win32 local file path URI preprocessing (#76)
Jonathan Hyrydad68dae329e
diff --git a/apps/desktop/src/main/file-system.ts b/apps/desktop/src/main/file-system.tsindex 59f195a4..361aa7cb 100644--- a/apps/desktop/src/main/file-system.ts+++ b/apps/desktop/src/main/file-system.ts@@ -1,4 +1,5 @@import fs from 'fs';+import os from 'os';import { Writable } from 'stream';import {@@ -57,6 +58,22 @@ export class DesktopFileSystem implements FileSystem {}public async url(path: string): Promise<string> {- return `local-file://${path}`;+ return `local-file://${DesktopFileSystem.win32PathPreUrl(path)}`;+ }++ public static win32PathPreUrl(path: string): string {+ if (os.platform() === 'win32') {+ let urlPath = path;+ let filePathPrefix = "";++ urlPath = urlPath.replace(/\\/g, '/');+ if (/^[a-zA-Z]:/.test(urlPath)) {+ filePathPrefix = '/';+ }++ return `${filePathPrefix}${urlPath}`;+ }++ return path;}}diff --git a/apps/desktop/src/main/protocols.ts b/apps/desktop/src/main/protocols.tsindex e55e812b..654ad81c 100644--- a/apps/desktop/src/main/protocols.ts+++ b/apps/desktop/src/main/protocols.ts@@ -2,6 +2,7 @@ import { net } from 'electron';import path from 'path';import { app } from '@colanode/desktop/main/app-service';+import { DesktopFileSystem } from '@colanode/desktop/main/file-system';export const handleAssetRequest = async (request: Request@@ -56,7 +57,8 @@ export const handleAssetRequest = async (export const handleFileRequest = async (request: Request): Promise<Response> => {- const url = request.url.replace('local-file://', '');- const fileUrl = `file://${url}`;- return net.fetch(fileUrl);+ return net.fetch(`file://${DesktopFileSystem.win32PathPreUrl(+ request.url.replace('local-file://', '')+ )}`+ );};