1234567891011121314151617181920212223242526272829303132333435363738 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = isBase32;
- var _assertString = _interopRequireDefault(require("./util/assertString"));
- var _merge = _interopRequireDefault(require("./util/merge"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- var base32 = /^[A-Z2-7]+=*$/;
- var crockfordBase32 = /^[A-HJKMNP-TV-Z0-9]+$/;
- var defaultBase32Options = {
- crockford: false
- };
- function isBase32(str, options) {
- (0, _assertString.default)(str);
- options = (0, _merge.default)(options, defaultBase32Options);
- if (options.crockford) {
- return crockfordBase32.test(str);
- }
- var len = str.length;
- if (len % 8 === 0 && base32.test(str)) {
- return true;
- }
- return false;
- }
- module.exports = exports.default;
- module.exports.default = exports.default;
|