CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-linkify-it

Links recognition library with FULL unicode support for detecting high-quality link patterns in plain text

Overall
score

97%

Overview
Eval results
Files

task.mdevals/scenario-6/

Link Detection Performance Optimizer

Problem Statement

You are building a content moderation system that processes large volumes of user-generated text comments. The system needs to detect links in comments for safety analysis. Comments are often very similar (spam, repeated content), and the same text may be checked multiple times during processing pipelines.

Your task is to build a performance-optimized link detection module that efficiently handles repeated link detection operations on text content.

Requirements

Input Processing

Your module should accept text strings and detect whether they contain any linkifiable content. The system will:

  1. Process batches of text strings that may contain duplicate or similar content
  2. Need to quickly reject text that definitely contains no links before performing full analysis
  3. Perform full link detection and extraction when links are likely present

Performance Optimization

The module must be optimized for performance when:

  • Processing the same text content multiple times
  • Quickly filtering out text that contains no links
  • Handling large batches where many strings are identical or similar

Output Requirements

Your module should provide:

  1. A fast preliminary check function that returns a boolean indicating if text might contain links (can have false positives for performance)
  2. A full detection function that returns all detected links with their details (position, URL, etc.)
  3. Efficient handling of repeated operations on identical text

Dependencies { .dependencies }

linkify-it { .dependency }

Provides link detection and recognition functionality.

Test Cases

Test Case 1: Fast Preliminary Check @test

Input:

Text: "Check out example.com for more info"
Text: "No links here just plain text"

Expected Behavior:

  • First text should return true from preliminary check (contains potential link)
  • Second text should return false from preliminary check (no potential links)
  • Preliminary check should be faster than full link detection

Test File: link-detector.test.js

Test Case 2: Repeated Text Processing @test

Input:

Text: "Visit https://github.com/user/repo for details"
Process the same text 100 times

Expected Behavior:

  • All 100 operations should complete efficiently
  • Subsequent operations on identical text should benefit from caching
  • Each operation should return consistent results

Test File: link-detector.test.js

Test Case 3: Link Extraction with Details @test

Input:

Text: "Contact us at support@example.com or visit www.example.com"

Expected Behavior:

  • Should extract both links (email and URL)
  • Should return position information for each link
  • Should provide normalized URL format for each link

Test File: link-detector.test.js

Implementation Notes

  • Focus on leveraging built-in performance optimization features
  • Consider how to efficiently handle repeated operations
  • Think about when to use fast checks versus full analysis

Install with Tessl CLI

npx tessl i tessl/npm-linkify-it

tile.json