| 1 | import { describe, expect, it } from 'vitest'; |
| 2 | |
| 3 | import { isValidAssetName, releaseAssetKey |
| 4 | |
| 5 | describe('releaseAssetKey', () |
| 6 | it('names an object, or the prefix of a release or repository', |
| 7 | expect(releaseAssetKey('repo_1 |
| 8 | 'release-assets/repo_1/release_1/asset_1', |
| 9 | ); |
| 10 | expect(releaseAssetKey('repo_1 |
| 11 | 'release-assets/repo_1/release_1/', |
| 12 | ); |
| 13 | expect(releaseAssetKey('repo_1 |
| 14 | }); |
| 15 | }); |
| 16 | |
| 17 | describe('isValidAssetName', () |
| 18 | it('accepts file names', |
| 19 | for (const name |
| 20 | 'app.zip', |
| 21 | 'ghost-v1.0.0-linux-x64.tar.gz', |
| 22 | 'a b (1).dmg', |
| 23 | ]) { |
| 24 | expect(isValidAssetName(name |
| 25 | } |
| 26 | }); |
| 27 | |
| 28 | it('refuses paths, dot names, control characters and empty or long names', |
| 29 | for (const name |
| 30 | '', |
| 31 | '.', |
| 32 | '..', |
| 33 | 'a/b', |
| 34 | 'a\\b', |
| 35 | 'a\nb', |
| 36 | 'x'.repeat(256 |
| 37 | ]) { |
| 38 | expect(isValidAssetName(name |
| 39 | } |
| 40 | }); |
| 41 | }); |