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

Custom Protocol Handler with Path Validation

Build a custom link recognizer that detects special "doc://" protocol links. These links should support standard URL paths with query parameters, but must validate that the path component only contains alphanumeric characters, hyphens, underscores, and forward slashes (no other special characters).

Requirements

Your implementation should:

  1. Create a custom schema handler for the "doc://" protocol
  2. Use the library's internal regex building blocks to construct the validation pattern
  3. Validate that URLs follow this format: doc://path/to/doc?optional=params
  4. The path portion (between doc:// and the query string or end) must only contain: letters, digits, hyphens, underscores, and forward slashes
  5. Query parameters (if present) should follow standard URL query string rules
  6. Export a configured instance that can detect these links in text

Test Cases

  • Detects a valid doc link: "Check doc://guides/intro" contains a valid link with URL "doc://guides/intro" @test
  • Detects doc link with query params: "See doc://api/methods?version=2" contains a valid link with URL "doc://api/methods?version=2" @test
  • Rejects invalid characters in path: "Invalid doc://path@with#special" should not detect a link (invalid path characters) @test
  • Detects multiple doc links: "Read doc://intro and doc://advanced" should find both links @test

Implementation

@generates

API

/**
 * A configured linkify-it instance with custom doc:// protocol support.
 * The instance uses internal regex building blocks to validate paths.
 */
module.exports = linkifyInstance;

Dependencies { .dependencies }

linkify-it { .dependency }

Provides link recognition with custom protocol extension support and access to internal regex patterns.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-linkify-it

tile.json