CodeSampleX

Пример

mustermann 4.0.0: Show that mustermann treats an explicitly empty wildcard path segment as present and distinguish it from an unmatched segment.

Проверенный пример — gem mustermann 4.0.0: Show that mustermann treats an explicitly empty wildcard path segment as present and distinguish it from an…

sha256:082e43ae1a14d53e8b7ca2cdca58e1ee1317439aeb2a675749b1254de6084a84

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
2
Ключи подписи, собравшие его
2
Заявленная среда ruby linux x64 ruby ruby bundler

Среды запусков проверки

Окружение Контракт Этапы Запуск
ruby 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-17
ruby 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-18

Кейс

HOW
Цель
Show that mustermann treats an explicitly empty wildcard path segment as present and distinguish it from an unmatched segment.
Пакеты
Символы
  • Mustermann#params
  • Mustermann::Match
Окружение
ruby
Создан
2026-08-17T01:18:19Z

Контракт

  1. A trailing slash on a wildcard route match yields an empty string capture rather than an absent nil value.
  2. assert_equal('', Mustermann.new('/files/*path').params('/files/')['path'])
  3. assert_nil Mustermann.new('/files/*path').params('/files')
  4. assert_equal('/files/', Mustermann.new('/files/*path').match('/files/').to_s)

Файлы

  • Gemfile
  • Gemfile.lock
  • NOTES.md
  • csx.json
  • test/contract.rb

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

Gemfile
# frozen_string_literal: true

source "https://rubygems.org"

gem "mustermann", "4.0.0"
Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    mustermann (4.0.0)

PLATFORMS
  ruby
  x64-mingw-ucrt
  x86_64-linux

DEPENDENCIES
  mustermann (= 4.0.0)

BUNDLED WITH
   2.6.9
NOTES.md
`search_known_solution` returned neighboring Mustermann 4.0.0 contracts for expansion, splat arrays, and match caching, but none proving this named empty-wildcard boundary.

A nil-or-absent expectation is wrong for this release: `/files/*path` matches `/files/` as `{"path"=>""}`, while `/files` does not match.
csx.json
{"case":{"believed":"A wildcard capture that has no characters before the next separator is absent, so a capture like `path` should be nil.","caseId":"case:sha256:3fc308591dfc26a97bcbf5623f3a88604db4b0e56064c0b23138aac0225fb4b5","contract":["A trailing slash on a wildcard route match yields an empty string capture rather than an absent nil value.","assert_equal('', Mustermann.new('/files/*path').params('/files/')['path'])","assert_nil Mustermann.new('/files/*path').params('/files')","assert_equal('/files/', Mustermann.new('/files/*path').match('/files/').to_s)"],"goal":"Show that mustermann treats an explicitly empty wildcard path segment as present and distinguish it from an unmatched segment.","kind":"HOW","packages":["pkg:gem/mustermann@4.0.0"],"schemaVersion":1,"symbols":["Mustermann#params","Mustermann::Match"]},"contractCommand":["bundle","exec","ruby","test/contract.rb"],"environment":{"arch":"x64","ecosystem":"gem","executionContext":"ruby","language":"ruby","os":"linux","packageManager":"bundler","runtime":"ruby","schemaVersion":1},"license":"MIT-0","packages":["pkg:gem/mustermann@4.0.0"],"schemaVersion":1,"symbols":["Mustermann#params","Mustermann::Match"],"verifierAdapter":"rubygems@1"}
test/contract.rb
# frozen_string_literal: true

require "mustermann"

route = Mustermann.new("/files/*path")
match_with_slash = route.params("/files/")
raise "expected wildcard capture to be empty string, got #{match_with_slash.fetch("path").inspect}" unless match_with_slash["path"] == ""
raise "expected no match without trailing slash, got #{route.params("/files").inspect}" unless route.params("/files").nil?
raise "expected matched path to round-trip" unless route.match("/files/").to_s == "/files/"

Исходный сидер

csx-seed