feat(core): Add Cargo and Composer registries with storage, auth and helpers
This commit is contained in:
@@ -65,22 +65,35 @@ export function pathToGAV(path: string): IMavenCoordinate | null {
|
||||
/**
|
||||
* Parse Maven artifact filename
|
||||
* Example: my-lib-1.0.0-sources.jar → {classifier: 'sources', extension: 'jar'}
|
||||
* Example: my-lib-1.0.0.jar.md5 → {extension: 'md5'}
|
||||
*/
|
||||
export function parseFilename(
|
||||
filename: string,
|
||||
artifactId: string,
|
||||
version: string
|
||||
): { classifier?: string; extension: string } | null {
|
||||
// Expected format: {artifactId}-{version}[-{classifier}].{extension}
|
||||
// Expected format: {artifactId}-{version}[-{classifier}].{extension}[.checksum]
|
||||
const prefix = `${artifactId}-${version}`;
|
||||
|
||||
if (!filename.startsWith(prefix)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const remainder = filename.substring(prefix.length);
|
||||
let remainder = filename.substring(prefix.length);
|
||||
|
||||
// Check for classifier
|
||||
// Check if this is a checksum file (double extension like .jar.md5)
|
||||
const checksumExtensions = ['md5', 'sha1', 'sha256', 'sha512'];
|
||||
const lastDotIndex = remainder.lastIndexOf('.');
|
||||
if (lastDotIndex !== -1) {
|
||||
const possibleChecksum = remainder.substring(lastDotIndex + 1);
|
||||
if (checksumExtensions.includes(possibleChecksum)) {
|
||||
// This is a checksum file - just return the checksum extension
|
||||
// The base artifact extension doesn't matter for checksum retrieval
|
||||
return { extension: possibleChecksum };
|
||||
}
|
||||
}
|
||||
|
||||
// Regular artifact file parsing
|
||||
const dotIndex = remainder.lastIndexOf('.');
|
||||
if (dotIndex === -1) {
|
||||
return null; // No extension
|
||||
|
||||
Reference in New Issue
Block a user