• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 33770738759
99%

Build:
DEFAULT BRANCH: master
Ran 03 Sep 2026 03:06PM UTC
Jobs 0
Files 0
Run time –
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
33770738759

push

github

web-flow
Scrub the format extension rather than the whole request path (#2893)

`format_from_extension` runs on every request, and scrubbed before it knew
whether there was anything to scrub:

    request_path = try_scrub(path_for_extension)
    dot_pos = request_path.rindex('.')
    return unless dot_pos

    extension = request_path[(dot_pos + 1)..]

`try_scrub` calls `valid_encoding?`, which walks the string, and `scrub`, which
walks and copies it — for a path that in the overwhelming majority of requests
carries no extension at all.

The scrub is only there for the extension, which `content_type_for` then looks
up; nothing between the two needs a valid string. `String#rindex` takes a byte
offset and does not raise on an invalid sequence, and `.` (0x2E) can never be
part of a UTF-8 multi-byte sequence — continuation bytes are 0x80..0xBF — so
the last dot sits at the same place before and after scrubbing, and slicing at
it gives the same extension either way. `"/info.\xNN"` still yields `"�"`.

    scrub whole path  177.2 ns  ->  scrub extension   81.5 ns  2.17x  short path
    scrub whole path  192.6 ns  ->  scrub extension   98.7 ns  1.95x  60-char path
    scrub whole path  273.6 ns  ->  scrub extension  271.9 ns  same   with .json

A path that does carry an extension pays what it always did, on a shorter
string. End to end this sits at the edge of what an interleaved `Benchmark.ips`
run can resolve (+1.1% on a minimal versioned GET, median of 5), so the
per-call figures above are the honest measurement.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Source Files on build 33770738759
Detailed source file information is not available for this build.
  • Back to Repo
  • Github Actions Build #33770738759
  • 79ad8511 on github
  • Prev Build on master (#33769456501)
  • Next Build on master (#33771232766)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc