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

URL Protocol Analyzer

Build a URL protocol analyzer that extracts and categorizes links from text based on their protocol types.

Problem

Create a tool that processes text input and identifies all URLs with explicit protocol prefixes (HTTP, HTTPS, and FTP). The tool should categorize discovered URLs by their protocol type and provide detailed information about each detected link.

Requirements

Input Processing

Your tool should accept text input and scan it for URLs that have explicit protocol prefixes. Only URLs beginning with http://, https://, or ftp:// should be detected.

Protocol Categorization

The tool must categorize detected URLs into three distinct groups:

  • HTTP protocol URLs (beginning with http://)
  • HTTPS protocol URLs (beginning with https://)
  • FTP protocol URLs (beginning with ftp://)

Output Format

For each detected URL, provide:

  • The complete URL as it appears in the text
  • The start position (index) in the input text
  • The end position (lastIndex) in the input text
  • The protocol type

Test Cases

  • Given text "Visit http://example.com for more info", it detects one HTTP URL at the correct position @test
  • Given text "Secure site: https://secure.example.org and file server ftp://files.example.net", it detects one HTTPS URL and one FTP URL @test
  • Given text "Check out example.com and www.site.org", it detects no URLs since they lack explicit protocols @test
  • Given text with multiple URLs "Download from ftp://ftp.gnu.org or https://downloads.example.com/file.zip", it correctly categorizes both URLs by protocol type @test

Implementation

@generates

API

/**
 * Analyzes text and extracts URLs with explicit HTTP, HTTPS, or FTP protocols.
 *
 * @param {string} text - The input text to analyze
 * @returns {Object} An object containing categorized URLs by protocol type
 * @returns {Array} returns.http - Array of HTTP URLs with metadata
 * @returns {Array} returns.https - Array of HTTPS URLs with metadata
 * @returns {Array} returns.ftp - Array of FTP URLs with metadata
 *
 * Each URL entry contains: { url, index, lastIndex, protocol }
 */
function analyzeProtocols(text) {
  // Implementation here
}

module.exports = { analyzeProtocols };

Dependencies { .dependencies }

linkify-it { .dependency }

Provides URL detection and link recognition capabilities with protocol identification.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-linkify-it

tile.json