|
12345678910111213141516171819202122232425262728293031323334 |
- //
- // Copyright (C) Stanislaw Adaszewski, 2020
- // Contact: s.adaszewski@gmail.com
- // Website: https://adared.ch/wba
- // License: GNU Affero General Public License, Version 3
- //
-
- function detectHashes(obj) {
- let Q = [ obj ];
- let matches = {};
-
- while (Q.length > 0) {
- let item = Q.pop();
-
- if (!item)
- continue;
-
- if (typeof(item) === 'string') {
- // use regexes
- let rx = /[a-f0-9]{32}\+[0-9]+/g;
- for (let m = rx.exec(item); m; m = rx.exec(item))
- matches[m[0]] = true;
-
- } else if (typeof(item) === 'object') {
- Object.keys(item).map(k => Q.push(item[k]));
- }
- }
-
- matches = Object.keys(matches);
-
- return matches;
- }
-
- export default detectHashes;
|