mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-22 02:14:10 +01:00
🔗 fix: Share Links Respect Custom Base Path (#11087)
* fix: share links respect base path Fixes #11072 * chore: import order * chore: import order --------- Co-authored-by: Dustin Healy <54083382+dustinhealy@users.noreply.github.com>
This commit is contained in:
parent
5740ca59d8
commit
9b6e7cabc9
5 changed files with 34 additions and 7 deletions
22
client/src/utils/__tests__/share.test.ts
Normal file
22
client/src/utils/__tests__/share.test.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
jest.mock('librechat-data-provider', () => ({
|
||||
apiBaseUrl: jest.fn(),
|
||||
}));
|
||||
|
||||
import { apiBaseUrl } from 'librechat-data-provider';
|
||||
import { buildShareLinkUrl } from '../share';
|
||||
|
||||
describe('buildShareLinkUrl', () => {
|
||||
it('includes the base path for subdirectory deployments', () => {
|
||||
(apiBaseUrl as jest.Mock).mockReturnValue('/librechat');
|
||||
expect(buildShareLinkUrl('reW8SsFGQEH1b1uzSHe4I')).toBe(
|
||||
'http://localhost:3080/librechat/share/reW8SsFGQEH1b1uzSHe4I',
|
||||
);
|
||||
});
|
||||
|
||||
it('works when base path is root', () => {
|
||||
(apiBaseUrl as jest.Mock).mockReturnValue('');
|
||||
expect(buildShareLinkUrl('reW8SsFGQEH1b1uzSHe4I')).toBe(
|
||||
'http://localhost:3080/share/reW8SsFGQEH1b1uzSHe4I',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
@ -23,6 +23,7 @@ export * from './roles';
|
|||
export * from './localStorage';
|
||||
export * from './promptGroups';
|
||||
export * from './email';
|
||||
export * from './share';
|
||||
export * from './timestamps';
|
||||
export { default as cn } from './cn';
|
||||
export { default as logger } from './logger';
|
||||
|
|
|
|||
6
client/src/utils/share.ts
Normal file
6
client/src/utils/share.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { apiBaseUrl } from 'librechat-data-provider';
|
||||
|
||||
export const buildShareLinkUrl = (shareId: string): string => {
|
||||
const baseURL = apiBaseUrl();
|
||||
return new URL(`${baseURL}/share/${shareId}`, window.location.origin).toString();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue