From b079fb31bc1987990421c154af52b4d52080adc1 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 17 Apr 2023 16:24:13 +0700 Subject: [PATCH] Replace Windows path separators in indexName configured via Khoj Obsidian Resolves #185, #199 - Issue IndexName created from Obsidian Absolute Vault path wasn't replacing windows path, drive separators with underscore. It was only replacing unix path separators - Fix Also replace windows drive and path separators with _ while creating IndexName in Khoj Obsidian plugin --- src/interface/obsidian/src/utils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/interface/obsidian/src/utils.ts b/src/interface/obsidian/src/utils.ts index 20e75574d..05fd1139f 100644 --- a/src/interface/obsidian/src/utils.ts +++ b/src/interface/obsidian/src/utils.ts @@ -10,7 +10,8 @@ export function getVaultAbsolutePath(vault: Vault): string { } export async function configureKhojBackend(vault: Vault, setting: KhojSetting, notify: boolean = true) { - let mdInVault = `${getVaultAbsolutePath(vault)}/**/*.md`; + let vaultPath = getVaultAbsolutePath(vault); + let mdInVault = `${vaultPath}/**/*.md`; let khojConfigUrl = `${setting.khojUrl}/api/config/data`; // Check if khoj backend is configured, note if cannot connect to backend @@ -28,7 +29,7 @@ export async function configureKhojBackend(vault: Vault, setting: KhojSetting, n if (!setting.connectedToBackend) return; // Set index name from the path of the current vault - let indexName = getVaultAbsolutePath(vault).replace(/\//g, '_').replace(/ /g, '_'); + let indexName = vaultPath.replace(/\//g, '_').replace(/\\/g, '_').replace(/ /g, '_').replace(/:/g, '_'); // Get default config fields from khoj backend let defaultConfig = await request(`${khojConfigUrl}/default`).then(response => JSON.parse(response)); let khojDefaultIndexDirectory = getIndexDirectoryFromBackendConfig(defaultConfig["content-type"]["markdown"]["embeddings-file"]);