示例
uri-js 4.4.1: parse
已验证示例 — npm uri-js 4.4.1: parse. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: assert parse decomposes standard hierarchical URIs into scheme, host…
sha256:0be5514e102532a0c966179755e5c2dc3216a8ba1497f3f9a682778c91041469
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-27 |
案例
HOW- 目标
- verify parse in pkg:npm/uri-js@4.4.1
- 符号
-
- parse
- 环境
- node 22.23.2
- 创建时间
- 2026-08-27T10:09:12Z
契约
- assert parse decomposes standard hierarchical URIs into scheme, host, port, path, query, fragment, and reference
- assert parse handles scheme-specific URIs including mailto, urn:uuid, and wss
- assert parse identifies relative references, path-only references, and same-document references
- assert parse with unicodeSupport decodes internationalized resource identifiers (IRIs)
- assert parse handles IPv6 host addresses and records scheme-specific validation errors
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- 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 parse in pkg:npm/uri-js@4.4.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/uri-js@4.4.1
Demonstrate these symbols/APIs:
- parse
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:225f64af3f9f6cf7384b60a5df22113dbed227fb9994a54914df77e47c46f8ad","contract":["assert parse decomposes standard hierarchical URIs into scheme, host, port, path, query, fragment, and reference","assert parse handles scheme-specific URIs including mailto, urn:uuid, and wss","assert parse identifies relative references, path-only references, and same-document references","assert parse with unicodeSupport decodes internationalized resource identifiers (IRIs)","assert parse handles IPv6 host addresses and records scheme-specific validation errors"],"goal":"verify parse in pkg:npm/uri-js@4.4.1","kind":"HOW","packages":["pkg:npm/uri-js@4.4.1"],"schemaVersion":1,"symbols":["parse"]},"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","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/uri-js@4.4.1"],"schemaVersion":1,"subject":"pkg:npm/uri-js@4.4.1","symbols":["parse"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-uri-js-parse",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-uri-js-parse",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"uri-js": "4.4.1"
}
},
"node_modules/punycode": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
"license": "BSD-2-Clause",
"dependencies": {
"punycode": "^2.1.0"
}
}
}
}
{
"name": "sample-uri-js-parse",
"version": "1.0.0",
"type": "module",
"license": "MIT-0",
"dependencies": {
"uri-js": "4.4.1"
}
}
{
"schemaVersion": 1,
"goal": "verify parse in pkg:npm/uri-js@4.4.1",
"kind": "HOW",
"packages": [
"pkg:npm/uri-js@4.4.1"
],
"symbols": [
"parse"
]
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const URI = require('uri-js');
// 1. parse decomposes standard hierarchical URIs into scheme, host, port, path, query, fragment, and reference
const p1 = URI.parse('https://example.com:8080/path/to/resource?query=val&key=1#section-1');
assert.equal(p1.scheme, 'https');
assert.equal(p1.userinfo, undefined);
assert.equal(p1.host, 'example.com');
assert.equal(p1.port, 8080);
assert.equal(p1.path, '/path/to/resource');
assert.equal(p1.query, 'query=val&key=1');
assert.equal(p1.fragment, 'section-1');
assert.equal(p1.reference, 'uri');
// 2. parse handles scheme-specific URIs including mailto, urn:uuid, and wss
const mailto = URI.parse('mailto:alice@example.com,bob@example.com?subject=Meeting&body=Hello');
assert.equal(mailto.scheme, 'mailto');
assert.deepEqual(mailto.to, ['alice@example.com', 'bob@example.com']);
assert.equal(mailto.subject, 'Meeting');
assert.equal(mailto.body, 'Hello');
const urnUuid = URI.parse('urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6');
assert.equal(urnUuid.scheme, 'urn');
assert.equal(urnUuid.nid, 'uuid');
assert.equal(urnUuid.uuid, 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6');
const wss = URI.parse('wss://example.com:8443/chat?room=general');
assert.equal(wss.scheme, 'wss');
assert.equal(wss.host, 'example.com');
assert.equal(wss.port, 8443);
assert.equal(wss.secure, true);
assert.equal(wss.resourceName, '/chat?room=general');
// 3. parse identifies relative references, path-only references, and same-document references
const netPath = URI.parse('//example.com/path/resource');
assert.equal(netPath.scheme, undefined);
assert.equal(netPath.host, 'example.com');
assert.equal(netPath.path, '/path/resource');
assert.equal(netPath.reference, 'relative');
const pathOnly = URI.parse('/catalog/products?page=2#top');
assert.equal(pathOnly.scheme, undefined);
assert.equal(pathOnly.host, undefined);
assert.equal(pathOnly.path, '/catalog/products');
assert.equal(pathOnly.query, 'page=2');
assert.equal(pathOnly.fragment, 'top');
assert.equal(pathOnly.reference, 'relative');
const sameDoc = URI.parse('#section-2');
assert.equal(sameDoc.fragment, 'section-2');
assert.equal(sameDoc.reference, 'same-document');
// 4. parse with unicodeSupport decodes internationalized resource identifiers (IRIs)
const iri = URI.parse('https://example.com/d%C3%B6m%C3%A4in?q=%E2%82%AC', { unicodeSupport: true });
assert.equal(iri.scheme, 'https');
assert.equal(iri.host, 'example.com');
assert.equal(iri.path, '/dömäin');
assert.equal(iri.query, 'q=€');
const nonIri = URI.parse('https://example.com/d%C3%B6m%C3%A4in?q=%E2%82%AC');
assert.equal(nonIri.path, '/d%C3%B6m%C3%A4in');
assert.equal(nonIri.query, 'q=%E2%82%AC');
// 5. parse handles IPv6 host addresses and records scheme-specific validation errors
const ipv6 = URI.parse('http://[::1]:8080/status');
assert.equal(ipv6.scheme, 'http');
assert.equal(ipv6.host, '::1');
assert.equal(ipv6.port, 8080);
assert.equal(ipv6.path, '/status');
const malformedHttp = URI.parse('http://');
assert.equal(malformedHttp.error, 'HTTP URIs must have a host.');
const malformedUuid = URI.parse('urn:uuid:invalid-uuid-format');
assert.equal(malformedUuid.error, 'UUID is not valid.');
原始种子者
匿名