fix(civitai): surface missing-model diagnostics and anchor image-page URL parsing

- Return the ResourceNotFoundError detail from get_civitai_versions and
  get_model_versions_status instead of a bare "Model not found", and let
  the download modal display the server-provided message
- Anchor extract_civitai_image_id / extractCivitaiImageId to
  ^/images/<id> so API paths and partial numeric IDs are rejected, same
  as the model-page parsing fix in #1140
This commit is contained in:
Will Miao
2026-10-09 08:12:56 +08:00
parent 01ffda7303
commit 18f3208468
9 changed files with 99 additions and 8 deletions
+1 -1
View File
@@ -1310,7 +1310,7 @@ export class BaseModelApiClient {
if (errorData && errorData.error && errorData.error.includes('Model type mismatch')) {
throw new Error(`This model is not a ${this.apiConfig.config.displayName}. Please switch to the appropriate page to download this model type.`);
}
throw new Error('Failed to fetch model versions');
throw new Error((errorData && errorData.error) || 'Failed to fetch model versions');
}
return await response.json();
} catch (error) {
+1 -1
View File
@@ -304,7 +304,7 @@ export function extractCivitaiImageId(url) {
return null;
}
const pathMatch = parsedUrl.pathname.match(/\/images\/(\d+)/);
const pathMatch = parsedUrl.pathname.match(/^\/images\/(\d+)(?:\/|$)/);
return pathMatch ? pathMatch[1] : null;
} catch (e) {
return null;