Source

validators/isURLSafeStr.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.URL_SAFE_REGEX_STR = exports.URL_SAFE_CHAR_REGEX_STR = void 0;
var CHAR_NUM_STR = 'a-zA-Z0-9';
exports.URL_SAFE_CHAR_REGEX_STR = "[".concat(CHAR_NUM_STR, "_-]");
exports.URL_SAFE_REGEX_STR = "".concat(exports.URL_SAFE_CHAR_REGEX_STR, "+");
// Case 1. length >= 3
var CASE_1 = "[".concat(CHAR_NUM_STR, "]").concat(exports.URL_SAFE_REGEX_STR, "[").concat(CHAR_NUM_STR, "]");
// Case 2. length <= 2
var CASE_2 = "[".concat(CHAR_NUM_STR, "]{1,2}");
// The start and the end must be characters of alphabets or numbers
var REGEX = new RegExp("^(".concat(CASE_1, "|").concat(CASE_2, ")$"), 'i');
/**
 * Whether it is an ID
 *
 * @param value
 * @category validators
 * @module isURLSafeStr
 */
var isURLSafeStr = function (value) { return REGEX.test("".concat(value)); };
exports.default = isURLSafeStr;