🐛 兼容新旧取件码并完善回收站复制
This commit is contained in:
1 parent
a5c5d1ae3b
commit
b2e1928898
10 files changed
+69
-16
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import ts from 'typescript'
|
||||
const root = new URL('../', import.meta.url)
|
||||
test('entry must not truncate new codes or submit before typing is complete', () => {
|
||||
const form = readFileSync(new URL('src/components/common/RetrieveForm.vue', root), 'utf8')
|
||||
const view = readFileSync(new URL('src/views/RetrievewFileView.vue', root), 'utf8')
|
||||
assert.ok(!form.includes('maxlength="5"'), '8-character code is truncated')
|
||||
assert.ok(!view.includes('watch(code,'), 'typing a legacy prefix must not consume a retrieval')
|
||||
})
|
||||
test('legacy/new codes and URL extraction preserve literal code', async () => {
|
||||
const source = readFileSync(new URL('src/utils/retrieval-code.ts', root), 'utf8')
|
||||
const js = ts.transpile(source, {module:ts.ModuleKind.ESNext,target:ts.ScriptTarget.ES2022})
|
||||
const {parseRetrievalCode, isValidRetrievalCode} = await import('data:text/javascript;base64,'+Buffer.from(js).toString('base64'))
|
||||
for (const code of ['01234','aB12C','00123456','Ab12Cd34']) {
|
||||
assert.equal(parseRetrievalCode(' '+code+' '),code)
|
||||
assert.equal(parseRetrievalCode('https://files.example/#/?code='+code),code)
|
||||
assert.equal(parseRetrievalCode('https://files.example/?code='+code),code)
|
||||
assert.equal(isValidRetrievalCode(code),true)
|
||||
}
|
||||
for (const code of ['1234','123456','1234567','123456789','12 34','../../foo']) assert.equal(isValidRetrievalCode(code),false)
|
||||
assert.equal(parseRetrievalCode('https://files.example/?code=bad#/?code=01234'),'')
|
||||
})
|
||||
Reference in new issue
Block a user