mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-12 22:47:12 +03:00
added get segments by hash prefix
This commit is contained in:
11
src/utils/hashPrefixTester.js
Normal file
11
src/utils/hashPrefixTester.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const config = require('../config.js');
|
||||
const logger = require('./logger.js');
|
||||
|
||||
const minimumPrefix = config.minimumPrefix || '3';
|
||||
const maximumPrefix = config.maximumPrefix || '32'; // Half the hash.
|
||||
|
||||
const prefixChecker = new RegExp('^[\\da-f]{' + minimumPrefix + ',' + maximumPrefix + '}$', 'i');
|
||||
|
||||
module.exports = (prefix) => {
|
||||
return prefixChecker.test(prefix);
|
||||
};
|
||||
Reference in New Issue
Block a user