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

URL Prefix Validator

A utility that validates whether user-provided URLs start with valid, fully-formed links and extracts their components for further processing.

Capabilities

Validates URLs at string start

  • Given the string "https://example.com/path and more text", returns true and extracts the link @test
  • Given the string "http://example.org additional content", returns true and extracts the link @test
  • Given the string "example.com text after", returns false because the URL lacks a protocol @test
  • Given the string " https://example.com", returns false because whitespace precedes the URL @test

Extracts link information

  • Given "https://example.com/path", extracts schema as "https:", url as "https://example.com/path", and raw text @test
  • Given "ftp://files.example.org/resource", extracts schema as "ftp:", url as "ftp://files.example.org/resource", and raw text @test

Handles edge cases

  • Given "https://", returns false because the URL is incomplete @test
  • Given "text before http://example.com", returns false because text precedes the URL @test

Implementation

@generates

API

/**
 * Validates whether a string starts with a fully-formed URL and extracts its information.
 *
 * @param {string} text - The text to validate.
 * @returns {Object|null} An object with { isValid: boolean, schema: string, url: string, raw: string } if a link is found at the start, or null otherwise.
 */
function validateUrlAtStart(text) {
  // IMPLEMENTATION HERE
}

module.exports = {
  validateUrlAtStart
};

Dependencies { .dependencies }

linkify-it { .dependency }

Provides link detection and matching capabilities for identifying URLs in text.

Install with Tessl CLI

npx tessl i tessl/npm-linkify-it

tile.json