From 55adac1ec5baceb8b60fe0148d1473ec6fd0497d Mon Sep 17 00:00:00 2001 From: Xi Xu Date: Wed, 20 Aug 2025 21:37:57 +0800 Subject: [PATCH] Add Civitai platform support Added 'civitai' to the PLATFORMS config and updated tests to include Civitai path transformations. This enables handling of Civitai URLs in the platform configuration and ensures correct path transformation logic. --- src/config/platforms.js | 1 + test/platforms.test.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/config/platforms.js b/src/config/platforms.js index e4b376f..09afad1 100644 --- a/src/config/platforms.js +++ b/src/config/platforms.js @@ -10,6 +10,7 @@ export const PLATFORMS = { sf: 'https://sourceforge.net', aosp: 'https://android.googlesource.com', hf: 'https://huggingface.co', + civitai: 'https://civitai.com', npm: 'https://registry.npmjs.org', pypi: 'https://pypi.org', 'pypi-files': 'https://files.pythonhosted.org', diff --git a/test/platforms.test.js b/test/platforms.test.js index 1636cb1..c8953c3 100644 --- a/test/platforms.test.js +++ b/test/platforms.test.js @@ -11,6 +11,7 @@ describe('Platform Configuration', () => { 'gitea', 'codeberg', 'hf', + 'civitai', 'npm', 'pypi', 'conda', @@ -79,6 +80,20 @@ describe('Platform Configuration', () => { ); }); + it('should transform Civitai paths correctly', () => { + expect(transformPath('/civitai/api/v1/models', 'civitai')).toBe( + '/api/v1/models' + ); + + expect(transformPath('/civitai/api/v1/model-versions/1318', 'civitai')).toBe( + '/api/v1/model-versions/1318' + ); + + expect(transformPath('/civitai/api/download/models/1105', 'civitai')).toBe( + '/api/download/models/1105' + ); + }); + it('should transform npm paths correctly', () => { expect(transformPath('/npm/react/-/react-18.2.0.tgz', 'npm')).toBe( '/react/-/react-18.2.0.tgz'