实现快传,完善快传和网盘的功能,实现文件的互传等一系列功能
This commit is contained in:
32
front/src/lib/file-share.test.ts
Normal file
32
front/src/lib/file-share.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import {
|
||||
buildFileShareUrl,
|
||||
FILE_SHARE_ROUTE_PREFIX,
|
||||
getPostLoginRedirectPath,
|
||||
} from './file-share';
|
||||
|
||||
test('buildFileShareUrl builds a browser-router share url', () => {
|
||||
assert.equal(
|
||||
buildFileShareUrl('https://yoyuzh.xyz', 'share-token-1', 'browser'),
|
||||
'https://yoyuzh.xyz/share/share-token-1',
|
||||
);
|
||||
});
|
||||
|
||||
test('buildFileShareUrl builds a hash-router share url', () => {
|
||||
assert.equal(
|
||||
buildFileShareUrl('https://yoyuzh.xyz/', 'share-token-1', 'hash'),
|
||||
'https://yoyuzh.xyz/#/share/share-token-1',
|
||||
);
|
||||
});
|
||||
|
||||
test('getPostLoginRedirectPath keeps safe in-site paths only', () => {
|
||||
assert.equal(getPostLoginRedirectPath('/share/share-token-1'), '/share/share-token-1');
|
||||
assert.equal(getPostLoginRedirectPath('https://evil.example.com'), '/overview');
|
||||
assert.equal(getPostLoginRedirectPath(null), '/overview');
|
||||
});
|
||||
|
||||
test('FILE_SHARE_ROUTE_PREFIX stays aligned with the public share route', () => {
|
||||
assert.equal(FILE_SHARE_ROUTE_PREFIX, '/share');
|
||||
});
|
||||
Reference in New Issue
Block a user