Links recognition library with FULL unicode support for detecting high-quality link patterns in plain text
Overall
score
97%
Build a link validator that can detect custom link patterns in text using configurable validation rules. The validator should support custom schemas with validation functions that can perform multi-stage checks on potential matches.
Your implementation should provide:
repo:, ticket:) with validation rules@generates
/**
* Creates a link validator with custom schema support
*/
class LinkValidator {
/**
* Add a custom schema with validation rules
* @param {string} schema - The schema prefix (e.g., 'repo:')
* @param {object} definition - Schema definition with validate function or regex
*/
addSchema(schema, definition) {
// IMPLEMENTATION HERE
}
/**
* Test if text contains any valid links
* @param {string} text - Text to check for links
* @returns {boolean} True if valid links are found
*/
test(text) {
// IMPLEMENTATION HERE
}
/**
* Find all valid links in text
* @param {string} text - Text to search
* @returns {Array|null} Array of match objects with schema, index, lastIndex, raw, url properties
*/
match(text) {
// IMPLEMENTATION HERE
}
}
module.exports = { LinkValidator };repo: schema with a regex validator that matches owner/name pattern should correctly detect repo:user/project in text @testticket: schema with a function validator that checks for numeric IDs should accept ticket:123 but reject ticket:abc @testProvides link detection and validation capabilities with custom schema support.
Install with Tessl CLI
npx tessl i tessl/npm-linkify-itdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10