fast-check
Version:
Property based testing framework for JavaScript (like QuickCheck)
32 lines (31 loc) • 1.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.hostUserInfo = exports.domain = void 0;
const ArrayArbitrary_1 = require("./ArrayArbitrary");
const SpecificCharacterRange_1 = require("./helpers/SpecificCharacterRange");
const OptionArbitrary_1 = require("./OptionArbitrary");
const StringArbitrary_1 = require("./StringArbitrary");
const TupleArbitrary_1 = require("./TupleArbitrary");
function subdomain() {
const alphaNumericArb = SpecificCharacterRange_1.buildLowerAlphaNumericArb([]);
const alphaNumericHyphenArb = SpecificCharacterRange_1.buildLowerAlphaNumericArb(['-']);
return TupleArbitrary_1.tuple(alphaNumericArb, OptionArbitrary_1.option(TupleArbitrary_1.tuple(StringArbitrary_1.stringOf(alphaNumericHyphenArb), alphaNumericArb)))
.map(([f, d]) => (d === null ? f : `${f}${d[0]}${d[1]}`))
.filter((d) => d.length <= 63)
.filter((d) => {
return d.length < 4 || d[0] !== 'x' || d[1] !== 'n' || d[2] !== '-' || d[3] !== '-';
});
}
function domain() {
const alphaNumericArb = SpecificCharacterRange_1.buildLowerAlphaArb([]);
const extensionArb = StringArbitrary_1.stringOf(alphaNumericArb, 2, 10);
return TupleArbitrary_1.tuple(ArrayArbitrary_1.array(subdomain(), 1, 5), extensionArb)
.map(([mid, ext]) => `${mid.join('.')}.${ext}`)
.filter((d) => d.length <= 255);
}
exports.domain = domain;
function hostUserInfo() {
const others = ['-', '.', '_', '~', '!', '$', '&', "'", '(', ')', '*', '+', ',', ';', '=', ':'];
return StringArbitrary_1.stringOf(SpecificCharacterRange_1.buildAlphaNumericPercentArb(others));
}
exports.hostUserInfo = hostUserInfo;