샘플
linkify-it 5.0.2
검증된 샘플 — npm linkify-it 5.0.2. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: LinkifyIt exports constructor function callable with or without new
sha256:079e9c4f53110b565552fc6676347d161a16bfdd2804a38d9afc3843bc727063
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-15 |
케이스
HOW- 목표
- verify pkg:npm/linkify-it@5.0.2
- 패키지
- 환경
- node 22.23.2
- 생성일
- 2026-09-15T02:58:12Z
컨트랙트
- LinkifyIt exports constructor function callable with or without new
- LinkifyIt.prototype.test validates URL presence in text and rejects non-URLs
- LinkifyIt.prototype.pretest quickly filters candidate text for possible links
- LinkifyIt.prototype.testSchemaAt validates schema prefix at specific string index
- LinkifyIt.prototype.match finds all links with offsets and normalized URLs
- LinkifyIt.prototype.matchAtStart detects link only when positioned at string start
- LinkifyIt.prototype.add registers custom protocol schema definitions with custom validation rules
- LinkifyIt.prototype.set toggles parser options including fuzzyEmail and fuzzyLink
- LinkifyIt.prototype.tlds registers additional top-level domains for recognition
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:npm/linkify-it@5.0.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/linkify-it@5.0.2
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:fadc8963990c93409c05e098994a34e2362c0164cc55759a91cdd8dd1056bcc2","contract":["LinkifyIt exports constructor function callable with or without new","LinkifyIt.prototype.test validates URL presence in text and rejects non-URLs","LinkifyIt.prototype.pretest quickly filters candidate text for possible links","LinkifyIt.prototype.testSchemaAt validates schema prefix at specific string index","LinkifyIt.prototype.match finds all links with offsets and normalized URLs","LinkifyIt.prototype.matchAtStart detects link only when positioned at string start","LinkifyIt.prototype.add registers custom protocol schema definitions with custom validation rules","LinkifyIt.prototype.set toggles parser options including fuzzyEmail and fuzzyLink","LinkifyIt.prototype.tlds registers additional top-level domains for recognition"],"goal":"verify pkg:npm/linkify-it@5.0.2","kind":"HOW","packages":["pkg:npm/linkify-it@5.0.2"],"schemaVersion":1,"symbols":["LinkifyIt","LinkifyIt.prototype.test","LinkifyIt.prototype.pretest","LinkifyIt.prototype.testSchemaAt","LinkifyIt.prototype.match","LinkifyIt.prototype.matchAtStart","LinkifyIt.prototype.add","LinkifyIt.prototype.set","LinkifyIt.prototype.tlds"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/linkify-it@5.0.2"],"schemaVersion":1,"subject":"pkg:npm/linkify-it@5.0.2","verifierAdapter":"node-typescript@1"}
{
"name": "sample-linkify-it",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-linkify-it",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"linkify-it": "5.0.2"
}
},
"node_modules/linkify-it": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz",
"integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/puzrin"
},
{
"type": "github",
"url": "https://github.com/sponsors/markdown-it"
}
],
"license": "MIT",
"dependencies": {
"uc.micro": "^2.0.0"
}
},
"node_modules/uc.micro": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz",
"integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==",
"license": "MIT"
}
}
}
{
"name": "sample-linkify-it",
"version": "1.0.0",
"private": true,
"description": "verify pkg:npm/linkify-it@5.0.2",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"linkify-it": "5.0.2"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/linkify-it@5.0.2",
"kind": "HOW",
"packages": [
"pkg:npm/linkify-it@5.0.2"
]
}
'use strict';
const LinkifyIt = require('linkify-it');
/**
* Creates and returns a configured LinkifyIt instance.
*
* @param {object} [schemas] - Optional custom schema definitions.
* @param {object} [options] - Optional configuration options.
* @returns {LinkifyIt} A new LinkifyIt instance.
*/
function createLinkifier(schemas, options) {
return new LinkifyIt(schemas, options);
}
/**
* Finds all links in the given text.
*
* @param {string} text - The text to scan for links.
* @param {object} [options] - Optional configuration overrides.
* @returns {Array<object>|null} Array of Match objects or null if none found.
*/
function extractLinks(text, options) {
const linkifier = new LinkifyIt(null, options);
return linkifier.match(text);
}
module.exports = {
LinkifyIt,
createLinkifier,
extractLinks
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { LinkifyIt, createLinkifier, extractLinks } = require('../src/index.js');
const rawLinkifyIt = require('linkify-it');
// 1. Module export verification and constructor invocation
assert.strictEqual(typeof LinkifyIt, 'function', 'LinkifyIt must be a constructor function');
assert.strictEqual(LinkifyIt, rawLinkifyIt, 'Exported LinkifyIt must match package export');
assert.strictEqual(typeof createLinkifier, 'function', 'createLinkifier helper must be a function');
assert.strictEqual(typeof extractLinks, 'function', 'extractLinks helper must be a function');
const instanceWithNew = new LinkifyIt();
assert.ok(instanceWithNew instanceof LinkifyIt, 'new LinkifyIt() should create an instance');
const instanceWithoutNew = LinkifyIt();
assert.ok(instanceWithoutNew instanceof LinkifyIt, 'LinkifyIt() without new should create an instance');
// 2. LinkifyIt.prototype.test validates URL presence
const linkify = new LinkifyIt();
assert.strictEqual(linkify.test('Check out https://example.com/docs'), true, 'Valid URL should return true');
assert.strictEqual(linkify.test('No link here at all'), false, 'Non-URL text should return false');
assert.strictEqual(linkify.test(''), false, 'Empty string should return false');
// 3. LinkifyIt.prototype.pretest quickly filters candidate text
assert.strictEqual(linkify.pretest('Check out https://example.com'), true, 'Pretest on URL text should return true');
assert.strictEqual(linkify.pretest('just plain text'), false, 'Pretest on plain text should return false');
// 4. LinkifyIt.prototype.testSchemaAt validates schema prefix at specific string index
const testText = 'prefix http://example.com suffix';
const pos = testText.indexOf('http://') + 'http:'.length;
assert.strictEqual(linkify.testSchemaAt(testText, 'http:', pos), 13, 'testSchemaAt should return length of matched tail');
assert.strictEqual(linkify.testSchemaAt(testText, 'http:', 0), 0, 'testSchemaAt at invalid position should return 0');
// 5. LinkifyIt.prototype.match finds all links with offsets and normalized URLs
const sampleText = 'First link https://example.com/a and second http://example.com/b done';
const matches = linkify.match(sampleText);
assert.ok(Array.isArray(matches), 'match should return an array');
assert.strictEqual(matches.length, 2, 'match should find exactly two links');
assert.strictEqual(matches[0].schema, 'https:', 'First match schema must be https:');
assert.strictEqual(matches[0].url, 'https://example.com/a', 'First match url must be normalized');
assert.strictEqual(matches[0].raw, 'https://example.com/a', 'First match raw text must match');
assert.strictEqual(matches[0].index, 11, 'First match index must be correct');
assert.strictEqual(matches[1].schema, 'http:', 'Second match schema must be http:');
assert.strictEqual(matches[1].url, 'http://example.com/b', 'Second match url must be normalized');
assert.strictEqual(linkify.match('no link in this string'), null, 'match should return null when no links exist');
// 6. LinkifyIt.prototype.matchAtStart detects link only at string start
const startMatch = linkify.matchAtStart('https://example.com trailing text');
assert.ok(startMatch !== null, 'matchAtStart should return match for link at start');
assert.strictEqual(startMatch.url, 'https://example.com', 'matchAtStart url should match');
const laterMatch = linkify.matchAtStart('leading text https://example.com');
assert.strictEqual(laterMatch, null, 'matchAtStart should return null when link is not at start');
// 7. LinkifyIt.prototype.add registers custom protocol schema definitions
const customLinkify = new LinkifyIt();
customLinkify.add('git:', 'http:');
assert.strictEqual(customLinkify.test('clone git://example.com/repo.git'), true, 'Custom git schema should be recognized');
const customMatches = customLinkify.match('git://example.com/repo.git');
assert.ok(customMatches !== null && customMatches.length === 1, 'Custom schema should match');
assert.strictEqual(customMatches[0].schema, 'git:', 'Custom schema should match git:');
assert.strictEqual(customMatches[0].url, 'git://example.com/repo.git', 'Custom schema url should match');
// 8. LinkifyIt.prototype.set toggles parser options
const optLinkify = new LinkifyIt();
assert.strictEqual(optLinkify.test('contact test@example.com'), true, 'Fuzzy email enabled by default');
optLinkify.set({ fuzzyEmail: false });
assert.strictEqual(optLinkify.test('contact test@example.com'), false, 'Fuzzy email disabled via set()');
assert.strictEqual(optLinkify.test('visit example.com'), true, 'Fuzzy link enabled by default');
optLinkify.set({ fuzzyLink: false });
assert.strictEqual(optLinkify.test('visit example.com'), false, 'Fuzzy link disabled via set()');
// 9. LinkifyIt.prototype.tlds registers additional top-level domains
const tldLinkify = new LinkifyIt();
assert.strictEqual(tldLinkify.test('visit site.mycustomdomaintest'), false, 'Unknown TLD should not be recognized');
tldLinkify.tlds('mycustomdomaintest');
assert.strictEqual(tldLinkify.test('visit site.mycustomdomaintest'), true, 'Added TLD should be recognized');
// 10. Helper functions verification
const helperInstance = createLinkifier();
assert.ok(helperInstance instanceof LinkifyIt, 'createLinkifier helper should return LinkifyIt instance');
const extracted = extractLinks('Check https://example.com and http://example.org');
assert.ok(Array.isArray(extracted) && extracted.length === 2, 'extractLinks should extract all links');
assert.strictEqual(extracted[0].url, 'https://example.com');
assert.strictEqual(extracted[1].url, 'http://example.org');
console.log('All linkify-it contract assertions passed.');
오리진 시더
익명