@wordpress/block-library
Version:
Block library for the WordPress editor.
1 lines • 1.21 kB
Source Map (JSON)
{"version":3,"file":"is-valid-link.cjs","names":["unlock","blockEditorPrivateApis","isEmail","isURL","prependHTTPS"],"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,eAAA,G,4BAAcA,CAAAA,CAAAA,OAAAA,CAAQC,wBAAAA,WAAuB;;;;;;;;;AAUrD,SAAwB,YAAa,KAAwB;CAC5D,IAAK,CAAE,KACN,OAAO;CAER,QAAA,GACCC,eAAAA,QAAAA,CAAS,GAAI,KACX,CAAC,CAAE,UAAW,GAAI,MAAA,GAAKC,eAAAA,MAAAA,EAAAA,GAAOC,eAAAA,aAAAA,CAAc,GAAI,CAAE;AAEtD"}