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-2/

Content Validator

Build a simple content validation tool that checks if user-generated text contains any linkifiable patterns (URLs, emails, etc.) and can be used to flag content for moderation.

Requirements

Create a validation function that:

  1. Accepts a text string as input
  2. Returns a boolean indicating whether the text contains any detectable links or link-like patterns
  3. Works with various types of linkifiable content including:
    • HTTP/HTTPS URLs (e.g., http://example.com, https://example.com)
    • URLs without protocols (e.g., example.com, www.example.com)
    • Email addresses (e.g., user@example.com)
    • FTP links (e.g., ftp://files.example.com)

The function should be efficient and handle edge cases like text with no links, empty strings, and text with multiple links.

API

/**
 * Checks if the given text contains any linkifiable patterns
 * @param {string} text - The text to check for links
 * @returns {boolean} True if text contains at least one link pattern, false otherwise
 */
function hasLinks(text) {
  // IMPLEMENTATION HERE
}

module.exports = { hasLinks };

Test Cases

  • When given text with an HTTP URL like "Check out http://example.com", it returns true @test
  • When given text with a domain without protocol like "Visit example.com for info", it returns true @test
  • When given text with an email like "Contact us at support@example.com", it returns true @test
  • When given plain text without any links like "Hello world", it returns false @test
  • When given an empty string, it returns false @test

Implementation

@generates

Dependencies { .dependencies }

linkify-it { .dependency }

Provides link detection and pattern recognition capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-linkify-it

tile.json