urlRegexFor function

RegExp urlRegexFor(
  1. String text
)

Returns the URL pattern to scan text with: the guarded one when its look-behind is provably a pure speed-up on this text, the plain one otherwise.

With none of _restartBlockerRegex present, every run of domain characters can be entered at its first label, and a match can only end at a TLD — with no : there is no scheme and no port, and with no / there is no path or query — which is the case _notMidLabelRun is sound for. Anything else falls back to the plain pattern, so the guard can never change what is extracted, only how long finding it takes.

Implementation

RegExp urlRegexFor(final String text) => _restartBlockerRegex.hasMatch(text)
    ? validUrlRegex
    : _validUrlWithoutMidLabelRestartsRegex;