@lobehub/chat 1.12.7 → 1.12.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.12.9](https://github.com/lobehub/lobe-chat/compare/v1.12.8...v1.12.9)
6
+
7
+ <sup>Released on **2024-08-23**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Improve s3 path-style url.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Improve s3 path-style url, closes [#3567](https://github.com/lobehub/lobe-chat/issues/3567) ([96bb38a](https://github.com/lobehub/lobe-chat/commit/96bb38a))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 1.12.8](https://github.com/lobehub/lobe-chat/compare/v1.12.7...v1.12.8)
31
+
32
+ <sup>Released on **2024-08-22**</sup>
33
+
34
+ #### 🐛 Bug Fixes
35
+
36
+ - **misc**: Fix `NEXT_PUBLIC_S3_DOMAIN` error on Docker.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### What's fixed
44
+
45
+ - **misc**: Fix `NEXT_PUBLIC_S3_DOMAIN` error on Docker, closes [#3564](https://github.com/lobehub/lobe-chat/issues/3564) ([bc6b64c](https://github.com/lobehub/lobe-chat/commit/bc6b64c))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ### [Version 1.12.7](https://github.com/lobehub/lobe-chat/compare/v1.12.6...v1.12.7)
6
56
 
7
57
  <sup>Released on **2024-08-22**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.12.7",
3
+ "version": "1.12.9",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -17,7 +17,7 @@ export const getFileConfig = () => {
17
17
  /**
18
18
  * @deprecated
19
19
  */
20
- NEXT_PUBLIC_S3_DOMAIN: z.string().url().optional(),
20
+ NEXT_PUBLIC_S3_DOMAIN: z.string().optional(),
21
21
  NEXT_PUBLIC_S3_FILE_PATH: z.string().optional(),
22
22
  },
23
23
  runtimeEnv: {
@@ -0,0 +1,36 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
+
3
+ import { fileEnv } from '@/config/file';
4
+
5
+ import { getFullFileUrl } from './files';
6
+
7
+ const config = {
8
+ S3_ENABLE_PATH_STYLE: false,
9
+ S3_PUBLIC_DOMAIN: 'https://example.com',
10
+ S3_BUCKET: 'my-bucket',
11
+ };
12
+
13
+ vi.mock('@/config/file', () => ({
14
+ get fileEnv() {
15
+ return config;
16
+ },
17
+ }));
18
+
19
+ describe('getFullFileUrl', () => {
20
+ it('should return empty string for null or undefined input', () => {
21
+ expect(getFullFileUrl(null)).toBe('');
22
+ expect(getFullFileUrl(undefined)).toBe('');
23
+ });
24
+
25
+ it('should return correct URL when S3_ENABLE_PATH_STYLE is false', () => {
26
+ const url = 'path/to/file.jpg';
27
+ expect(getFullFileUrl(url)).toBe('https://example.com/path/to/file.jpg');
28
+ });
29
+
30
+ it('should return correct URL when S3_ENABLE_PATH_STYLE is true', () => {
31
+ config.S3_ENABLE_PATH_STYLE = true;
32
+ const url = 'path/to/file.jpg';
33
+ expect(getFullFileUrl(url)).toBe('https://example.com/my-bucket/path/to/file.jpg');
34
+ config.S3_ENABLE_PATH_STYLE = false;
35
+ });
36
+ });
@@ -5,5 +5,9 @@ import { fileEnv } from '@/config/file';
5
5
  export const getFullFileUrl = (url?: string | null) => {
6
6
  if (!url) return '';
7
7
 
8
+ if (fileEnv.S3_ENABLE_PATH_STYLE) {
9
+ return urlJoin(fileEnv.S3_PUBLIC_DOMAIN!, fileEnv.S3_BUCKET!, url);
10
+ }
11
+
8
12
  return urlJoin(fileEnv.S3_PUBLIC_DOMAIN!, url);
9
13
  };