Update
This commit is contained in:
26
frontend/src/utils/signatureParser.ts
Normal file
26
frontend/src/utils/signatureParser.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { SigviewRecord as Signature } from "@/lib/pbtypes";
|
||||
|
||||
export const parseSignature = (text: string): Omit<Signature, 'system' | 'id' | 'sysid'> | null => {
|
||||
const parts = text.split('\t');
|
||||
if (parts.length < 4) return null;
|
||||
|
||||
// Validate signature identifier format (3 letters, dash, 3 numbers)
|
||||
const signatureIdentifierRegex = /^\w{3}-\d{3}$/;
|
||||
if (!signatureIdentifierRegex.test(parts[0])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
identifier: parts[0],
|
||||
type: parts[2],
|
||||
signame: parts[3],
|
||||
scanned: parts.length > 4 ? parts[4] : undefined,
|
||||
dangerous: false // TODO: Implement dangerous signature detection
|
||||
};
|
||||
};
|
||||
|
||||
export const parseScannedPercentage = (scannedString?: string): number => {
|
||||
if (!scannedString) return 0;
|
||||
const match = scannedString.match(/(\d+(?:\.\d+)?)%/);
|
||||
return match ? parseFloat(match[1]) : 0;
|
||||
};
|
Reference in New Issue
Block a user