diff --git a/README.en.md b/README.en.md index 5e083f4..71b5ba6 100644 --- a/README.en.md +++ b/README.en.md @@ -139,6 +139,7 @@ Using the pre-deployed instance **`xget.xi-xu.me`** or your own deployed instanc | Platform | Platform Prefix | Original URL Format | Accelerated URL Format | |----------|----------------|---------------------|------------------------| | GitHub | `gh` | `https://github.com/...` | `https://xget.xi-xu.me/gh/...` | +| GitHub Gist | `gist` | `https://gist.github.com/...` | `https://xget.xi-xu.me/gist/...` | | GitLab | `gl` | `https://gitlab.com/...` | `https://xget.xi-xu.me/gl/...` | | Gitea | `gitea` | `https://gitea.com/...` | `https://xget.xi-xu.me/gitea/...` | | Codeberg | `codeberg` | `https://codeberg.org/...` | `https://xget.xi-xu.me/codeberg/...` | @@ -185,6 +186,16 @@ https://github.com/microsoft/vscode/archive/refs/heads/main.zip https://xget.xi-xu.me/gh/microsoft/vscode/archive/refs/heads/main.zip ``` +#### GitHub Gist + +```url +# Original URL +https://gist.github.com/xixu-me/e2ea9db6b1f143892495f796fef18631/raw/3b8807172ee492d0da3a7e370b0fb88fc97b53e6/Free-ChatGPT-Paid-Plan.md + +# Converted (add gist prefix) +https://xget.xi-xu.me/gist/xixu-me/e2ea9db6b1f143892495f796fef18631/raw/3b8807172ee492d0da3a7e370b0fb88fc97b53e6/Free-ChatGPT-Paid-Plan.md +``` + #### GitLab ```url diff --git a/README.md b/README.md index 664c94e..88c6f84 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ | 平台 | 平台前缀 | 原始 URL 格式 | 加速 URL 格式 | |------|----------|--------------|--------------| | GitHub | `gh` | `https://github.com/...` | `https://xget.xi-xu.me/gh/...` | +| GitHub Gist | `gist` | `https://gist.github.com/...` | `https://xget.xi-xu.me/gist/...` | | GitLab | `gl` | `https://gitlab.com/...` | `https://xget.xi-xu.me/gl/...` | | Gitea | `gitea` | `https://gitea.com/...` | `https://xget.xi-xu.me/gitea/...` | | Codeberg | `codeberg` | `https://codeberg.org/...` | `https://xget.xi-xu.me/codeberg/...` | @@ -194,6 +195,16 @@ https://github.com/microsoft/vscode/archive/refs/heads/main.zip https://xget.xi-xu.me/gh/microsoft/vscode/archive/refs/heads/main.zip ``` +#### GitHub Gist + +```url +# 原始 URL +https://gist.github.com/xixu-me/e2ea9db6b1f143892495f796fef18631/raw/3b8807172ee492d0da3a7e370b0fb88fc97b53e6/Free-ChatGPT-Paid-Plan.md + +# 转换后(添加 gist 前缀) +https://xget.xi-xu.me/gist/xixu-me/e2ea9db6b1f143892495f796fef18631/raw/3b8807172ee492d0da3a7e370b0fb88fc97b53e6/Free-ChatGPT-Paid-Plan.md +``` + #### GitLab ```url diff --git a/src/config/platforms.js b/src/config/platforms.js index 8334199..8865655 100644 --- a/src/config/platforms.js +++ b/src/config/platforms.js @@ -4,6 +4,7 @@ */ export const PLATFORMS = { gh: 'https://github.com', + gist: 'https://gist.github.com', gl: 'https://gitlab.com', gitea: 'https://gitea.com', codeberg: 'https://codeberg.org', diff --git a/test/platforms.test.js b/test/platforms.test.js index 8e84861..c79b84a 100644 --- a/test/platforms.test.js +++ b/test/platforms.test.js @@ -6,6 +6,7 @@ describe('Platform Configuration', () => { it('should have all required platforms defined', () => { const requiredPlatforms = [ 'gh', + 'gist', 'gl', 'sf', 'gitea', @@ -46,6 +47,14 @@ describe('Platform Configuration', () => { expect(transformPath('/gh/user/repo.git', 'gh')).toBe('/user/repo.git'); }); + it('should transform GitHub Gist paths correctly', () => { + expect(transformPath('/gist/username/gist-id/raw/file.txt', 'gist')).toBe( + '/username/gist-id/raw/file.txt' + ); + + expect(transformPath('/gist/username/gist-id.git', 'gist')).toBe('/username/gist-id.git'); + }); + it('should transform GitLab paths correctly', () => { expect(transformPath('/gl/gitlab-org/gitlab/-/archive/master/gitlab-master.zip', 'gl')).toBe( '/gitlab-org/gitlab/-/archive/master/gitlab-master.zip' @@ -141,6 +150,10 @@ describe('Platform Configuration', () => { expect(PLATFORMS.gh).toBe('https://github.com'); }); + it('should have correct GitHub Gist base URL', () => { + expect(PLATFORMS.gist).toBe('https://gist.github.com'); + }); + it('should have correct GitLab base URL', () => { expect(PLATFORMS.gl).toBe('https://gitlab.com'); });