CodeSampleX

Beispiel

react-router-dom 6.30.4: matchPath

Verifiziertes Beispiel für npm react-router-dom 6.30.4: matchPath. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:986fc61d51d9dafe3995e433505853938ccafb12bae159c58c647cfc0a5e59c8

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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-01

Fall

HOW
Ziel
verify matchPath in pkg:npm/react-router-dom@6.30.4
Pakete
Symbole
  • matchPath
Umgebung
node 22.23.2
Erstellt
2026-09-01T15:58:01Z

Contract

  1. react-router-dom package.json declares version 6.30.4 and exports matchPath
  2. matchPath matches exact static paths and extracts parameterized segments into params object
  3. matchPath returns null when pathname does not match the pattern or fails end constraint
  4. matchPath supports PathPattern object with caseSensitive and end options
  5. matchPath matches wildcard splat routes and captures wildcard segment in params["*"]

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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 matchPath in pkg:npm/react-router-dom@6.30.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/react-router-dom@6.30.4
Demonstrate these symbols/APIs:
  - matchPath

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:d84a3494a2feca652751274455a8aa218fa19b00a1cde8c6d6bd12f0b6ea3015","contract":["react-router-dom package.json declares version 6.30.4 and exports matchPath","matchPath matches exact static paths and extracts parameterized segments into params object","matchPath returns null when pathname does not match the pattern or fails end constraint","matchPath supports PathPattern object with caseSensitive and end options","matchPath matches wildcard splat routes and captures wildcard segment in params[\"*\"]"],"goal":"verify matchPath in pkg:npm/react-router-dom@6.30.4","kind":"HOW","packages":["pkg:npm/react-router-dom@6.30.4"],"schemaVersion":1,"symbols":["matchPath"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/react-router-dom@6.30.4"],"schemaVersion":1,"subject":"pkg:npm/react-router-dom@6.30.4","symbols":["matchPath"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-react-router-dom-matchpath",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-react-router-dom-matchpath",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "react-router-dom": "6.30.4"
      }
    },
    "node_modules/@remix-run/router": {
      "version": "1.23.3",
      "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.23.3.tgz",
      "integrity": "sha512-4An71tdz9X8+3sI4Qqqd2LWd9vS39J7sqd9EU4Scw7TJE/qB10Flv/UuqbPVgfQV9XoK8Np6jNquZitnZq5i+Q==",
      "license": "MIT",
      "engines": {
        "node": ">=14.0.0"
      }
    },
    "node_modules/react": {
      "version": "19.2.8",
      "resolved": "https://registry.npmjs.org/react/-/react-19.2.8.tgz",
      "integrity": "sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==",
      "license": "MIT",
      "peer": true,
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/react-dom": {
      "version": "19.2.8",
      "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.8.tgz",
      "integrity": "sha512-rVprimfGBG3DR+Tq0IQG2DT5PxKth1WIGDmj5yPmlzr4YBe7uyE+Du4oVqTDXZSHGGGXRtTJEGSSePyQCMBglQ==",
      "license": "MIT",
      "peer": true,
      "dependencies": {
        "scheduler": "^0.27.0"
      },
      "peerDependencies": {
        "react": "^19.2.8"
      }
    },
    "node_modules/react-router": {
      "version": "6.30.4",
      "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.30.4.tgz",
      "integrity": "sha512-SVUsDe+DybHM/WmYKIVYhZh1o5Dcuf16yM6WjG02Q9XVFMZIJyHYhwrr6bFBXZkVP6z69kNkMyBCujt8FaFLJA==",
      "license": "MIT",
      "dependencies": {
        "@remix-run/router": "1.23.3"
      },
      "engines": {
        "node": ">=14.0.0"
      },
      "peerDependencies": {
        "react": ">=16.8"
      }
    },
    "node_modules/react-router-dom": {
      "version": "6.30.4",
      "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.30.4.tgz",
      "integrity": "sha512-q4HvNl+mmDdkS0g+MqiBZNteQJCuimWoOyHMy4T/RQLAn9Z29+E91QXRaxOujeMl2HTzRSS0KFPd7lxX3PjV0Q==",
      "license": "MIT",
      "dependencies": {
        "@remix-run/router": "1.23.3",
        "react-router": "6.30.4"
      },
      "engines": {
        "node": ">=14.0.0"
      },
      "peerDependencies": {
        "react": ">=16.8",
        "react-dom": ">=16.8"
      }
    },
    "node_modules/scheduler": {
      "version": "0.27.0",
      "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz",
      "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==",
      "license": "MIT",
      "peer": true
    }
  }
}
package.json
{
  "name": "sample-react-router-dom-matchpath",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "license": "MIT-0",
  "dependencies": {
    "react-router-dom": "6.30.4"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify matchPath in pkg:npm/react-router-dom@6.30.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react-router-dom@6.30.4"
  ],
  "symbols": [
    "matchPath"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import { createRequire } from 'node:module';
import { matchPath } from 'react-router-dom';

const require = createRequire(import.meta.url);

// Contract 1: react-router-dom package.json declares version 6.30.4 and exports matchPath
{
  const pkgJsonPath = require.resolve('react-router-dom/package.json');
  assert.ok(fs.existsSync(pkgJsonPath));
  const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
  assert.strictEqual(pkgJson.name, 'react-router-dom');
  assert.strictEqual(pkgJson.version, '6.30.4');
  assert.strictEqual(typeof matchPath, 'function');
}

// Contract 2: matchPath matches exact static paths and extracts parameterized segments into params object
{
  const match = matchPath('/users/:userId/posts/:postId', '/users/42/posts/108');
  assert.notStrictEqual(match, null);
  assert.strictEqual(match.pathname, '/users/42/posts/108');
  assert.strictEqual(match.pathnameBase, '/users/42/posts/108');
  assert.deepStrictEqual(match.params, { userId: '42', postId: '108' });
  assert.deepStrictEqual(match.pattern, {
    path: '/users/:userId/posts/:postId',
    caseSensitive: false,
    end: true
  });
}

// Contract 3: matchPath returns null when pathname does not match the pattern or fails end constraint
{
  const mismatch = matchPath('/users/:userId', '/orders/42');
  assert.strictEqual(mismatch, null);

  const prefixOnlyWithDefaultEnd = matchPath('/users', '/users/42');
  assert.strictEqual(prefixOnlyWithDefaultEnd, null);
}

// Contract 4: matchPath supports PathPattern object with caseSensitive and end options
{
  // caseSensitive: false (default) matches case-insensitively
  const insensitiveMatch = matchPath({ path: '/app/dashboard', caseSensitive: false, end: true }, '/APP/DASHBOARD');
  assert.notStrictEqual(insensitiveMatch, null);
  assert.strictEqual(insensitiveMatch.pathname, '/APP/DASHBOARD');

  // caseSensitive: true fails on case mismatch
  const sensitiveMismatch = matchPath({ path: '/app/dashboard', caseSensitive: true, end: true }, '/APP/DASHBOARD');
  assert.strictEqual(sensitiveMismatch, null);

  // end: false matches prefixes
  const prefixMatch = matchPath({ path: '/files', end: false }, '/files/documents/readme.txt');
  assert.notStrictEqual(prefixMatch, null);
  assert.strictEqual(prefixMatch.pathname, '/files');
  assert.strictEqual(prefixMatch.pathnameBase, '/files');
}

// Contract 5: matchPath matches wildcard splat routes and captures wildcard segment in params["*"]
{
  const splatMatch = matchPath('/docs/*', '/docs/api/v2/reference');
  assert.notStrictEqual(splatMatch, null);
  assert.strictEqual(splatMatch.params['*'], 'api/v2/reference');
  assert.strictEqual(splatMatch.pathname, '/docs/api/v2/reference');
  assert.strictEqual(splatMatch.pathnameBase, '/docs');
}

console.log('All matchPath contract tests passed.');

Ursprungs-Seeder

anonym