实现快传,完善快传和网盘的功能,实现文件的互传等一系列功能

This commit is contained in:
yoyuzh
2026-03-20 14:16:18 +08:00
parent 944ab6dbf8
commit 43358e29d7
109 changed files with 5237 additions and 2465 deletions

View 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');
});