Adjust encoder/decoder fallbacks (#750)

* Adjust encoder/decoder fallbacks

* Dep-dup is functions

* Complexity cleanups
This commit is contained in:
Jaco Greeff
2020-11-08 11:20:22 +01:00
committed by GitHub
parent e1aa096cef
commit c67c1966d7
18 changed files with 118 additions and 78 deletions
+6 -2
View File
@@ -3,10 +3,14 @@
import validate from './validate';
export default function isBase32 (value?: string | null): boolean {
export function testValidator (validate: (value?: string | null, ipfsCompat?: boolean) => boolean, value?: string | null, ipfsCompat?: boolean): boolean {
try {
return validate(value);
return validate(value, ipfsCompat);
} catch (error) {
return false;
}
}
export default function isBase32 (value?: string | null, ipfsCompat?: boolean): boolean {
return testValidator(validate, value, ipfsCompat);
}