CodeSampleX

Exemplo

@jridgewell/resolve-uri 3.1.2: resolve-uri

Amostra verificada para npm @jridgewell/resolve-uri 3.1.2: resolve-uri. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.

sha256:ea00140b437268290ad15d2b50a8a45f08157d58b216a1a9616ad081169b009a

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
2
Chaves de assinatura que o compilaram
1
Ambiente declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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
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-07

Caso

HOW
Objetivo
verify resolve-uri in pkg:npm/%40jridgewell/resolve-uri@3.1.2
Pacotes
Símbolos
  • resolve-uri
Ambiente
node 22.23.2
Criado
2026-08-26T05:12:37Z

Contrato

  1. resolve-uri resolves relative paths against a base HTTP URL
  2. resolve-uri resolves root-relative absolute paths against base origin
  3. resolve-uri resolves query parameters and fragment hashes against base URL
  4. resolve-uri resolves scheme-relative URLs inheriting scheme from base
  5. resolve-uri resolves relative paths against relative base paths
  6. resolve-uri returns input unchanged when input is already an absolute URL
  7. resolve-uri handles empty strings and undefined base gracefully

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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 resolve-uri in pkg:npm/%40jridgewell/resolve-uri@3.1.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40jridgewell/resolve-uri@3.1.2
Demonstrate these symbols/APIs:
  - resolve-uri
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.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.
csx.json
{"case":{"caseId":"case:sha256:31894e2ca7bc8ff8feec2bbc2e8af9b5037e1bd73b51647e89820ef9a05ce12b","constraints":{"executionContext":"node"},"contract":["resolve-uri resolves relative paths against a base HTTP URL","resolve-uri resolves root-relative absolute paths against base origin","resolve-uri resolves query parameters and fragment hashes against base URL","resolve-uri resolves scheme-relative URLs inheriting scheme from base","resolve-uri resolves relative paths against relative base paths","resolve-uri returns input unchanged when input is already an absolute URL","resolve-uri handles empty strings and undefined base gracefully"],"goal":"verify resolve-uri in pkg:npm/%40jridgewell/resolve-uri@3.1.2","kind":"HOW","packages":["pkg:npm/%40jridgewell/resolve-uri@3.1.2"],"schemaVersion":1,"symbols":["resolve-uri"]},"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/%40jridgewell/resolve-uri@3.1.2"],"schemaVersion":1,"subject":"pkg:npm/%40jridgewell/resolve-uri@3.1.2","symbols":["resolve-uri"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-resolve-uri",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-resolve-uri",
      "version": "1.0.0",
      "dependencies": {
        "@jridgewell/resolve-uri": "3.1.2"
      }
    },
    "node_modules/@jridgewell/resolve-uri": {
      "version": "3.1.2",
      "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
      "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
      "license": "MIT",
      "engines": {
        "node": ">=6.0.0"
      }
    }
  }
}
package.json
{
  "name": "sample-resolve-uri",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "@jridgewell/resolve-uri": "3.1.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify resolve-uri in pkg:npm/%40jridgewell/resolve-uri@3.1.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40jridgewell/resolve-uri@3.1.2"
  ],
  "symbols": [
    "resolve-uri"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import resolveURI from '@jridgewell/resolve-uri';

// 1. resolve-uri resolves relative paths against a base HTTP URL
{
  assert.equal(resolveURI('baz.js', 'https://example.com/foo/bar/'), 'https://example.com/foo/bar/baz.js');
  assert.equal(resolveURI('baz.js', 'https://example.com/foo/bar/index.html'), 'https://example.com/foo/bar/baz.js');
  assert.equal(resolveURI('../baz.js', 'https://example.com/foo/bar/'), 'https://example.com/foo/baz.js');
  assert.equal(resolveURI('../../baz.js', 'https://example.com/foo/bar/'), 'https://example.com/baz.js');
}

// 2. resolve-uri resolves root-relative absolute paths against base origin
{
  assert.equal(resolveURI('/baz.js', 'https://example.com/foo/bar/'), 'https://example.com/baz.js');
  assert.equal(resolveURI('/app/bundle.js', 'https://example.com:8080/nested/path/'), 'https://example.com:8080/app/bundle.js');
}

// 3. resolve-uri resolves query parameters and fragment hashes against base URL
{
  assert.equal(resolveURI('?query=1&page=2', 'https://example.com/foo/bar'), 'https://example.com/foo/bar?query=1&page=2');
  assert.equal(resolveURI('#section-1', 'https://example.com/foo/bar'), 'https://example.com/foo/bar#section-1');
  assert.equal(resolveURI('?query=1#section-1', 'https://example.com/foo/bar'), 'https://example.com/foo/bar?query=1#section-1');
}

// 4. resolve-uri resolves scheme-relative URLs inheriting scheme from base
{
  assert.equal(resolveURI('//cdn.example.com/assets/app.js', 'https://example.com/page'), 'https://cdn.example.com/assets/app.js');
  assert.equal(resolveURI('//cdn.example.com/assets/app.js', 'http://example.com/page'), 'http://cdn.example.com/assets/app.js');
}

// 5. resolve-uri resolves relative paths against relative base paths
{
  assert.equal(resolveURI('bar.js', './src/'), './src/bar.js');
  assert.equal(resolveURI('../dist/bundle.js', './src/components/'), './src/dist/bundle.js');
  assert.equal(resolveURI('file.txt', 'dir/sub/'), 'dir/sub/file.txt');
}

// 6. resolve-uri returns input unchanged when input is already an absolute URL
{
  assert.equal(resolveURI('https://other.example.com/api', 'https://example.com/app'), 'https://other.example.com/api');
  assert.equal(resolveURI('http://example.org/', 'https://example.com/'), 'http://example.org/');
}

// 7. resolve-uri handles empty strings and undefined base gracefully
{
  assert.equal(resolveURI('', ''), '');
  assert.equal(resolveURI('foo.js', undefined), 'foo.js');
  assert.equal(resolveURI('', 'https://example.com/path/'), 'https://example.com/path/');
}

Seeder de origem

anônimo