mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[bugfix] fix playlist maps with malformed hash doesnt get loaded + improve playlist maps reading reliability
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
const HashAlgorithmsLengths = {
|
||||
sha1: 40,
|
||||
} as const;
|
||||
|
||||
export function findHashInString(str: string, algorithm: keyof typeof HashAlgorithmsLengths = 'sha1'): string | undefined {
|
||||
|
||||
if(!str) { return undefined; }
|
||||
|
||||
const hashLength = HashAlgorithmsLengths[algorithm];
|
||||
const regex = new RegExp(`[a-fA-F0-9]{${hashLength}}`, "g");
|
||||
const match = str.match(regex);
|
||||
return match ? match[0] : undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user