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:
co-authored by
Claude Opus 4.7
parent
715909d552
commit
e57448f704
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user