@wordpress/block-library
Version:
Block library for the WordPress editor.
24 lines (23 loc) • 932 B
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_block_editor = require("@wordpress/block-editor");
let _wordpress_url = require("@wordpress/url");
// packages/block-library/src/social-link/is-valid-link.ts
const { isURLLike } = (0, require("../lock-unlock.cjs").unlock)(_wordpress_block_editor.privateApis);
/**
* Returns whether a Social Icon's link looks valid: a URL, with or without
* its protocol, or an email address for the Mail icon. It uses the same check
* as the link popover, and an empty link is valid.
*
* @param url The link.
* @return Whether the link is valid.
*/
function isValidLink(url) {
if (!url) return true;
return (0, _wordpress_url.isEmail)(url) || !!isURLLike(url) && (0, _wordpress_url.isURL)((0, _wordpress_url.prependHTTPS)(url));
}
exports.default = isValidLink;
//# sourceMappingURL=is-valid-link.cjs.map