CodeSampleX

샘플

uri-js 4.4.1: parse

검증된 샘플 — npm uri-js 4.4.1: parse. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: assert parse decomposes standard hierarchical URIs into scheme…

sha256:0be5514e102532a0c966179755e5c2dc3216a8ba1497f3f9a682778c91041469

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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

컨트랙트

  1. assert parse decomposes standard hierarchical URIs into scheme, host, port, path, query, fragment, and reference
  2. assert parse handles scheme-specific URIs including mailto, urn:uuid, and wss
  3. assert parse identifies relative references, path-only references, and same-document references
  4. assert parse with unicodeSupport decodes internationalized resource identifiers (IRIs)
  5. 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

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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.
csx.json
{"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"}
package-lock.json
{
  "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"
      }
    }
  }
}
package.json
{
  "name": "sample-uri-js-parse",
  "version": "1.0.0",
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "uri-js": "4.4.1"
  }
}
spec.json
{
  "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"
  ]
}
test/contract.mjs
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.');

오리진 시더

익명