Add support for GitHub Gist platform

Added GitHub Gist ('gist') to the supported platforms in the configuration, updated documentation in both English and Chinese READMEs, and included related tests to ensure correct path transformation and base URL.
This commit is contained in:
xixu-me committed 2025-11-10 20:45:58 +08:00
1 parent 2a02852a5d
commit 6245da9e6f
4 files changed
+36

No files matched your search

+11
View File
@@ -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
+11
View File
@@ -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
+1
View File
@@ -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',
+13
View File
@@ -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');
});