CodeSampleX

サンプル

uri-js 4.4.1: serialize

検証済みサンプル — npm uri-js 4.4.1: serialize. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: assert serialize constructs absolute HTTP/HTTPS URI from…

sha256:942390d8fa71ca13d3eaa8a1cd85df6daf7bf62e47665079b6a6036f53ba0aa8

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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 serialize in pkg:npm/uri-js@4.4.1
パッケージ
シンボル
  • serialize
環境
node 22.23.2
作成日
2026-08-27T10:08:48Z

コントラクト

  1. assert serialize constructs absolute HTTP/HTTPS URI from components
  2. assert serialize formats network-path and relative-path references
  3. assert serialize handles IPv6 host formatting with brackets
  4. assert serialize formats scheme-specific mailto components
  5. assert serialize formats scheme-specific URN components
  6. assert serialize formats WebSocket URI components
  7. assert serialize applies unicodeSupport and iri options for internationalized URIs

ファイル

  • 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 serialize 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:
  - serialize

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:3694d3fdd582f6f3f5709d67f15968c98856b84c08afdc0a3e8a01836f9dedd4","contract":["assert serialize constructs absolute HTTP/HTTPS URI from components","assert serialize formats network-path and relative-path references","assert serialize handles IPv6 host formatting with brackets","assert serialize formats scheme-specific mailto components","assert serialize formats scheme-specific URN components","assert serialize formats WebSocket URI components","assert serialize applies unicodeSupport and iri options for internationalized URIs"],"goal":"verify serialize in pkg:npm/uri-js@4.4.1","kind":"HOW","packages":["pkg:npm/uri-js@4.4.1"],"schemaVersion":1,"symbols":["serialize"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","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":["serialize"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-uri-js-serialize",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-uri-js-serialize",
      "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-serialize",
  "version": "1.0.0",
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "uri-js": "4.4.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify serialize in pkg:npm/uri-js@4.4.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/uri-js@4.4.1"
  ],
  "symbols": [
    "serialize"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import * as URI from 'uri-js';

// 1. serialize constructs absolute HTTP/HTTPS URI from components
const httpUri = URI.serialize({
  scheme: 'https',
  host: 'example.com',
  port: 8443,
  path: '/api/v1/resource',
  query: 'filter=active&sort=desc',
  fragment: 'section-2'
});
assert.equal(httpUri, 'https://example.com:8443/api/v1/resource?filter=active&sort=desc#section-2');

// 2. serialize formats network-path and relative-path references
const networkPath = URI.serialize({
  host: 'cdn.example.com',
  path: '/assets/app.js'
});
assert.equal(networkPath, '//cdn.example.com/assets/app.js');

const relativeUri = URI.serialize({
  path: 'docs/readme.html',
  query: 'lang=en'
});
assert.equal(relativeUri, 'docs/readme.html?lang=en');

// 3. serialize handles IPv6 host formatting with brackets
const ipv6Uri = URI.serialize({
  scheme: 'http',
  host: '::1',
  port: 8080,
  path: '/status'
});
assert.equal(ipv6Uri, 'http://[::1]:8080/status');

// 4. serialize formats scheme-specific mailto components
const mailtoUri = URI.serialize({
  scheme: 'mailto',
  to: ['alice@example.com', 'bob@example.com'],
  subject: 'Project Update',
  body: 'Hello Team'
});
assert.equal(mailtoUri, 'mailto:alice@example.com,bob@example.com?subject=Project%20Update&body=Hello%20Team');

// 5. serialize formats scheme-specific URN components
const urnUri = URI.serialize({
  scheme: 'urn',
  nid: 'uuid',
  uuid: 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
});
assert.equal(urnUri, 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6');

// 6. serialize formats WebSocket URI components
const wsUri = URI.serialize({
  scheme: 'wss',
  host: 'example.com',
  port: 9001,
  resourceName: '/ws/stream?channel=events'
});
assert.equal(wsUri, 'wss://example.com:9001/ws/stream?channel=events');

// 7. serialize applies unicodeSupport and iri options for internationalized URIs
const iriEncoded = URI.serialize({
  scheme: 'https',
  host: 'example.com',
  path: '/dömäin',
  query: 'currency=€'
}, { unicodeSupport: true });
assert.equal(iriEncoded, 'https://example.com/d%C3%B6m%C3%A4in?currency=%E2%82%AC');

const iriDecoded = URI.serialize({
  scheme: 'https',
  host: 'xn--fsq.example',
  path: '/%E4%BD%A0%E5%A5%BD'
}, { iri: true });
assert.equal(iriDecoded, 'https://例.example/你好');

オリジンシーダー

匿名