feat(archive): add rar extraction support

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-01 12:55:10 +02:00
co-authored by Claude Sonnet 5
parent a66143d312
commit ceddeddf3e
6 changed files with 60 additions and 0 deletions
+29
View File
@@ -228,3 +228,32 @@ describe('archive converters — 7z and tar.7z', () => {
20000
);
});
describe('archive converters — rar (extraction only)', () => {
it('lists rar as a source with the other 6 archive formats as targets, and never lists rar as a target for anything', () => {
const targets = listTargetFormats('rar');
expect(targets.sort()).toEqual(['7z', 'tar', 'tar.7z', 'tar.bz2', 'tar.gz', 'zip'].sort());
expect(listTargetFormats('zip')).not.toContain('rar');
});
it('converts the sample.rar fixture to zip', async () => {
const rarPath = path.join(import.meta.dirname, '..', 'fixtures', 'sample.rar');
const outputPath = path.join(tmpDir, 'from-rar.zip');
const entry = resolve('rar', 'zip');
await entry.convert(rarPath, outputPath);
const outZip = new AdmZip(outputPath);
expect(outZip.getEntries().length).toBeGreaterThan(0);
});
});
describe('archive converters — full registration matrix', () => {
it('registers all 42 source/target pairs (7 sources x 6 targets)', () => {
const sources = ['zip', 'tar', 'tar.gz', 'tar.bz2', '7z', 'tar.7z', 'rar'];
const targets = ['zip', 'tar', 'tar.gz', 'tar.bz2', '7z', 'tar.7z'];
for (const source of sources) {
expect(listTargetFormats(source).sort()).toEqual(targets.sort());
}
});
});
+9
View File
@@ -0,0 +1,9 @@
# RAR fixture attribution
`sample.rar` is a byte-identical copy of `testFiles/FolderTest.rar` from the
[YuJianrong/node-unrar.js](https://github.com/YuJianrong/node-unrar.js)
repository (MIT-licensed), used there for that project's own extraction
tests. Reused here because there is no way to create a `.rar` fixture from
this codebase — the `unrar` library's license bars any tool (including this
project's own converters) from writing the RAR format, so RAR support is
extraction-only everywhere, including in test fixtures.
BIN
View File
Binary file not shown.