UNPKG

@atlaskit/adf-schema

Version:

Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs

32 lines (30 loc) 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getLinkMatch = getLinkMatch; var _linkifyMatch = require("./linkify-match"); var _url = require("./url"); /** * This file has been partially duplicated in packages/linking-platform/linking-common/src/url.ts * Any changes made here should be mirrored there. * Ticket for dedeplication: https://product-fabric.atlassian.net/browse/EDM-7138 * Ticket for fixing linkification of filename-like urls: https://product-fabric.atlassian.net/browse/EDM-7190 */ /** * Attempt to find a link match. Tries to use our regex search first. * If this doesn't match (e.g. no protocol), try using linkify-it library. * Returns null if url string empty or no string given, or if no match found. */ function getLinkMatch(str) { if (!str) { return null; } // linkify-it mishandles closing braces on long urls, so we preference using our own regex first: // https://product-fabric.atlassian.net/browse/ED-13669 var match = (0, _linkifyMatch.linkifyMatch)(str); if (!match.length) { match = _url.linkify.match(str); } return match && match[0]; }