CodeSampleX

Exemple

fast-uri 3.1.5: equal, normalize, parse

Échantillon vérifié pour npm fast-uri 3.1.5: equal, normalize, parse. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.

sha256:d2fe077a6b80d0efac23857e6d3477c877ff182e09dbbfb13e116e4cc9143092

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré linux 24 · ubuntu · glibc 2.39 x64 npm

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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-26

Cas

HOW
Objectif
verify pkg:npm/fast-uri@3.1.5
Paquets
Symboles
  • equal
  • normalize
  • parse
  • resolve
  • resolveComponent
  • serialize
Créé
2026-08-26T07:31:16Z

Contrat

  1. fastUri.parse parses full URI into scheme, host, port, path, query, and fragment components
  2. fastUri.parse parses relative paths without scheme or authority
  3. fastUri.parse parses IPv6 host literals and reports error property on malformed domains
  4. fastUri.serialize formats URI component objects into complete URI strings
  5. fastUri.serialize formats relative URI component objects with path and query parameters
  6. fastUri.resolve resolves relative paths, absolute-path references, and query string references against a base URI
  7. fastUri.resolveComponent resolves parsed relative URIComponent against parsed base URIComponent
  8. fastUri.normalize normalizes host casing, path dot-segments, and unreserved percent-encoded characters
  9. fastUri.equal determines RFC 3986 equivalence between equivalent URI strings

Fichiers

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Télécharger l’artefact source (tar.gz)

Code source

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 pkg:npm/fast-uri@3.1.5
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/fast-uri@3.1.5
Demonstrate these symbols/APIs:
  - equal
  - normalize
  - parse
  - resolve
  - resolveComponent
  - 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:1913b5b31a33578ecee13bc18e682c80eb92f354f2965a04f5820c26dd84bbf9","contract":["fastUri.parse parses full URI into scheme, host, port, path, query, and fragment components","fastUri.parse parses relative paths without scheme or authority","fastUri.parse parses IPv6 host literals and reports error property on malformed domains","fastUri.serialize formats URI component objects into complete URI strings","fastUri.serialize formats relative URI component objects with path and query parameters","fastUri.resolve resolves relative paths, absolute-path references, and query string references against a base URI","fastUri.resolveComponent resolves parsed relative URIComponent against parsed base URIComponent","fastUri.normalize normalizes host casing, path dot-segments, and unreserved percent-encoded characters","fastUri.equal determines RFC 3986 equivalence between equivalent URI strings"],"goal":"verify pkg:npm/fast-uri@3.1.5","kind":"HOW","packages":["pkg:npm/fast-uri@3.1.5"],"schemaVersion":1,"symbols":["equal","normalize","parse","resolve","resolveComponent","serialize"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/fast-uri@3.1.5"],"schemaVersion":1,"subject":"pkg:npm/fast-uri@3.1.5","symbols":["equal","normalize","parse","resolve","resolveComponent","serialize"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "fast-uri-verification",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "fast-uri-verification",
      "version": "1.0.0",
      "dependencies": {
        "fast-uri": "3.1.5"
      }
    },
    "node_modules/fast-uri": {
      "version": "3.1.5",
      "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.5.tgz",
      "integrity": "sha512-gHwA1O9LDIcKunMKhObS/HimwtehO1nPUECKAu5TpKgaO19fcWEl4bliWe1jWxVFvIXztJjjQ4L8XQ1EU9f7Jw==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/fastify"
        },
        {
          "type": "opencollective",
          "url": "https://opencollective.com/fastify"
        }
      ],
      "license": "BSD-3-Clause"
    }
  }
}
package.json
{
  "name": "fast-uri-verification",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for fast-uri",
  "dependencies": {
    "fast-uri": "3.1.5"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/fast-uri@3.1.5",
  "kind": "HOW",
  "packages": [
    "pkg:npm/fast-uri@3.1.5"
  ],
  "symbols": [
    "equal",
    "normalize",
    "parse",
    "resolve",
    "resolveComponent",
    "serialize"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import uri from 'fast-uri';

// 1. fastUri.parse parses full URI into scheme, host, port, path, query, and fragment components
const parsed = uri.parse('http://example.com:8080/path/sub?q=test#heading');
assert.strictEqual(parsed.scheme, 'http');
assert.strictEqual(parsed.host, 'example.com');
assert.strictEqual(parsed.port, 8080);
assert.strictEqual(parsed.path, '/path/sub');
assert.strictEqual(parsed.query, 'q=test');
assert.strictEqual(parsed.fragment, 'heading');
assert.strictEqual(parsed.reference, 'uri');

// 2. fastUri.parse parses relative paths without scheme or authority
const rel = uri.parse('/api/v1/users?page=2#top');
assert.strictEqual(rel.scheme, undefined);
assert.strictEqual(rel.host, undefined);
assert.strictEqual(rel.port, undefined);
assert.strictEqual(rel.path, '/api/v1/users');
assert.strictEqual(rel.query, 'page=2');
assert.strictEqual(rel.fragment, 'top');
assert.strictEqual(rel.reference, 'relative');

// 3. fastUri.parse parses IPv6 host literals and reports error property on malformed domains
const ipv6 = uri.parse('http://[::1]:3000/');
assert.strictEqual(ipv6.scheme, 'http');
assert.strictEqual(ipv6.host, '::1');
assert.strictEqual(ipv6.port, 3000);
const malformed = uri.parse('http://invalid domain with spaces');
assert.ok(malformed.error);

// 4. fastUri.serialize formats URI component objects into complete URI strings
const serialized = uri.serialize({
  scheme: 'http',
  host: 'example.com',
  port: 8080,
  path: '/api/resource',
  query: 'filter=active',
  fragment: 'section1'
});
assert.strictEqual(serialized, 'http://example.com:8080/api/resource?filter=active#section1');

// 5. fastUri.serialize formats relative URI component objects with path and query parameters
const relSerialized = uri.serialize({
  path: '/docs',
  query: 'lang=en'
});
assert.strictEqual(relSerialized, '/docs?lang=en');

// 6. fastUri.resolve resolves relative paths, absolute-path references, and query string references against a base URI
assert.strictEqual(uri.resolve('http://example.com/a/b/c', '../d'), 'http://example.com/a/d');
assert.strictEqual(uri.resolve('http://example.com/a/b/c', '/main/target'), 'http://example.com/main/target');
assert.strictEqual(uri.resolve('http://example.com/a/b', '?filter=all'), 'http://example.com/a/b?filter=all');
assert.strictEqual(uri.resolve('http://example.com/a/b', '#section2'), 'http://example.com/a/b#section2');

// 7. fastUri.resolveComponent resolves parsed relative URIComponent against parsed base URIComponent
const baseComp = uri.parse('http://example.com/a/b');
const relComp = uri.parse('c');
const resolvedComp = uri.resolveComponent(baseComp, relComp);
assert.strictEqual(resolvedComp.scheme, 'http');
assert.strictEqual(resolvedComp.host, 'example.com');
assert.strictEqual(resolvedComp.path, '/a/c');

// 8. fastUri.normalize normalizes host casing, path dot-segments, and unreserved percent-encoded characters
assert.strictEqual(uri.normalize('http://EXAMPLE.COM/a/b/../c/%7A'), 'http://example.com/a/c/z');
assert.strictEqual(uri.normalize('http://example.com/a/./b'), 'http://example.com/a/b');

// 9. fastUri.equal determines RFC 3986 equivalence between equivalent URI strings
assert.strictEqual(uri.equal('http://EXAMPLE.COM/a/b/../c/%7A', 'http://example.com/a/c/z'), true);
assert.strictEqual(uri.equal('http://example.com:8080/test', 'http://example.com:8080/test'), true);
assert.strictEqual(uri.equal('http://example.com/a', 'http://example.com/b'), false);

console.log('Contract passed');

Seeder d'origine

anonyme