UNPKG

@azizbecha/strkit

Version:

strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.

29 lines 1.18 kB
(function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = isIPv6Address; /** * Validates whether a given string is a valid IPv6 address. * * @param str - The string to check if it's a valid IPv6 address. * @returns A boolean indicating whether the string is a valid IPv6 address. * * @example * isIPv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); // Output: true * isIPv6Address("::1"); // Output: true * isIPv6Address("not-an-ipv6"); // Output: false */ function isIPv6Address(str) { const ipv6Regex = /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^::(?:[0-9a-fA-F]{1,4}:){0,7}[0-9a-fA-F]{1,4}$|^(?:[0-9a-fA-F]{1,4}:){1,7}:$/; return ipv6Regex.test(str); } }); //# sourceMappingURL=isIPv6Address.js.map