@wordpress/block-library
Version:
Block library for the WordPress editor.
1 lines • 1.08 kB
Source Map (JSON)
{"version":3,"file":"is-valid-link.mjs","names":["blockEditorPrivateApis"],"sources":["../../src/social-link/is-valid-link.ts"],"sourcesContent":["import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { isEmail, isURL, prependHTTPS } from '@wordpress/url';\nimport { unlock } from '../lock-unlock';\n\nconst { isURLLike } = unlock( blockEditorPrivateApis );\n\n/**\n * Returns whether a Social Icon's link looks valid: a URL, with or without\n * its protocol, or an email address for the Mail icon. It uses the same check\n * as the link popover, and an empty link is valid.\n *\n * @param url The link.\n * @return Whether the link is valid.\n */\nexport default function isValidLink( url?: string ): boolean {\n\tif ( ! url ) {\n\t\treturn true;\n\t}\n\treturn (\n\t\tisEmail( url ) ||\n\t\t( !! isURLLike( url ) && isURL( prependHTTPS( url ) ) )\n\t);\n}\n"],"mappings":";;;;AAIA,MAAM,EAAE,cAAc,OAAQA,WAAuB;;;;;;;;;AAUrD,SAAwB,YAAa,KAAwB;CAC5D,IAAK,CAAE,KACN,OAAO;CAER,OACC,QAAS,GAAI,KACX,CAAC,CAAE,UAAW,GAAI,KAAK,MAAO,aAAc,GAAI,CAAE;AAEtD"}