fix(settings): delete model button — encode HF repo_id per segment (#19)

`encodeURIComponent("voxcpm2/voxcpm2-2B-EC")` turns the slash into
`%2F`, which some ASGI layers reject or fail to roundtrip through the
`:path` converter. Frontend was sending `/models/voxcpm2%2Fvoxcpm2-2B-EC`
and getting a silent no-op (or 404 swallowed by the busy-state wrapper).

Encode each path segment instead so special chars in the repo name
still escape but the slash survives as a literal `/` in the URL.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Palash Debnath
2026-04-23 06:38:38 +05:30
committed by GitHub
co-authored by Claude Opus 4.7
parent 715909d552
commit e57448f704
+6 -1
View File
@@ -97,7 +97,12 @@ export async function getRecommendations(): Promise<Recommendations> {
}
export async function deleteModel(repo_id: string): Promise<{ deleted: boolean; repo_id: string; freed_bytes: number }> {
const r = await apiFetch(`/models/${encodeURIComponent(repo_id)}`, { method: 'DELETE' });
// HF repo_ids look like "owner/name" — encode each segment so special chars
// are escaped but the literal "/" survives into FastAPI's `:path` converter.
// encodeURIComponent on the whole string would turn "/" into "%2F", which
// some ASGI middleware rejects as a path-traversal attempt.
const path = repo_id.split('/').map(encodeURIComponent).join('/');
const r = await apiFetch(`/models/${path}`, { method: 'DELETE' });
return r.json();
}