Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
refactor(utils): add helper to remove extensions from file paths
Roushan Singhc6be66e5959f
diff --git a/extensions/llamacpp-extension/src/util.ts b/extensions/llamacpp-extension/src/util.tsindex 1511eafec..b72766579 100644--- a/extensions/llamacpp-extension/src/util.ts+++ b/extensions/llamacpp-extension/src/util.ts@@ -1,3 +1,23 @@+// File path utilities+export function basenameNoExt(filePath: string): string {+ const VALID_EXTENSIONS = [".tar.gz", ".zip"];++ // handle VALID extensions first+ for (const ext of VALID_EXTENSIONS) {+ if (filePath.toLowerCase().endsWith(ext)) {+ return filePath.slice(0, -ext.length);+ }+ }++ // fallback: remove only the last extension+ const lastDotIndex = filePath.lastIndexOf('.');+ if (lastDotIndex > 0) {+ return filePath.slice(0, lastDotIndex);+ }++ return filePath;+}+// Zustand proxy state structureinterface ProxyState {proxyEnabled: booleandiff --git a/web-app/src/lib/utils.ts b/web-app/src/lib/utils.tsindex 60a055720..d9bfa0ecb 100644--- a/web-app/src/lib/utils.ts+++ b/web-app/src/lib/utils.ts@@ -1,11 +1,28 @@import { type ClassValue, clsx } from 'clsx'import { twMerge } from 'tailwind-merge'import { ExtensionManager } from './extension'+import path from "path"export function cn(...inputs: ClassValue[]) {return twMerge(clsx(inputs))}++export function basenameNoExt(filePath: string): string {+ const base = path.basename(filePath);+ const VALID_EXTENSIONS = [".tar.gz", ".zip"];++ // handle VALID extensions first+ for (const ext of VALID_EXTENSIONS) {+ if (base.toLowerCase().endsWith(ext)) {+ return base.slice(0, -ext.length);+ }+ }++ // fallback: remove only the last extension+ return base.slice(0, -path.extname(base).length);+}+export function getProviderLogo(provider: string) {switch (provider) {case 'jan':