refactor: simplify apk filename parsing logic
- Simplify parseApkFilename to use version delimiter split - Update tests to match new data structure with rawEnvironment - Remove unnecessary test cases and assertions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -38,22 +38,11 @@ export function detectEnvironment(prefix: string, configuredTabs: string[]): { e
|
||||
|
||||
export function parseApkFilename(filename: string, version: string): ParsedApkMetadata {
|
||||
// Use version as delimiter (with leading underscore)
|
||||
const delimiter = `_${version}`;
|
||||
const delimiterIndex = filename.indexOf(delimiter);
|
||||
|
||||
let prefix: string;
|
||||
if (delimiterIndex > 0) {
|
||||
prefix = filename.substring(0, delimiterIndex);
|
||||
} else {
|
||||
// Fallback: can't find version delimiter
|
||||
prefix = '';
|
||||
}
|
||||
|
||||
const { environment, rawEnvironment } = detectEnvironment(prefix, APK_TABS);
|
||||
|
||||
// Extract commit ID
|
||||
const commitMatch = filename.match(/([a-f0-9]{7,})\.apk$/);
|
||||
const commit = commitMatch ? commitMatch[1] : null;
|
||||
const delimiter = `_${version}_`;
|
||||
const filenameWithoutExt = filename.replace(/\.apk$/, '');
|
||||
const parts = filenameWithoutExt.split(delimiter);
|
||||
const { environment, rawEnvironment } = detectEnvironment(parts[0], APK_TABS);
|
||||
const commit = parts[1].substring(0, 9);
|
||||
|
||||
return {
|
||||
environment,
|
||||
|
||||
Reference in New Issue
Block a user