laravel-streams / streams-core

Streams is an open-source web application engine for Laravel.
https://streams.dev
Other
169 stars 99 forks source link

Replace linkify by Url highlight 2.0 #708

Closed vstelmakh closed 3 years ago

vstelmakh commented 3 years ago

Same as #706, but for v2 branch. Additionally extracted and refactored humanize and truncate to StringHelper class. This gives possibility to add unit tests.

Added unit tests for all mentioned above.

Not sure if this is a direction how you plan to have it, but at least, could be usefull as an ideas/code parts.

RyanThompson commented 3 years ago

Is UrlHilight more performant than Linkify?

vstelmakh commented 3 years ago

Is UrlHilight more performant than Linkify?

I haven't done much comparison but for some dummy input text (32860 chars, contains 52 urls of different complexity), on Intel Core i7-6700 CPU @ 3.40GHz, PHP 7.4.10, I got next results:

Results could vary, depends on input content and url amount, but generally it's slower. That's the downside of covering more cases.

But if you compare the results, Linkify would not do proper matching, and mess with some a tags. For example:

See full results html in attachment: results.zip. It's enough to open results in different browser tabs, to see the difference.

vstelmakh commented 3 years ago

@RyanThompson Are you interested in this changes? Should I resolve the conflicts or close the PR?