Skip to content

Commit

Permalink
Replace Windows path separators in indexName configured via Khoj Obsi…
Browse files Browse the repository at this point in the history
…dian

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
  • Loading branch information
debanjum committed Apr 17, 2023
1 parent d90df96 commit b079fb3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/interface/obsidian/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]);
Expand Down

0 comments on commit b079fb3

Please sign in to comment.