Skip to content

fix: refuse an empty or dot path id so a request cannot land on a sibling route - #25

Merged
robrigo merged 1 commit into
mainfrom
fix/path-segment-guard
Aug 17, 2026
Merged

fix: refuse an empty or dot path id so a request cannot land on a sibling route#25
robrigo merged 1 commit into
mainfrom
fix/path-segment-guard

Conversation

@robrigo

@robrigo robrigo commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Why

Every path-building read percent-encodes its ids, but encodeURIComponent leaves dots alone, so an id of . or .. survives into the path and the URL parser inside fetch collapses it onto the route above; an empty id turns a single-row route into its list. The caller reads rows it never asked for instead of seeing a failure. None of those values is ever an id, a name, or an account, so the path builder now throws before the request, naming the field, and a missing value is refused the same way. Dotted Antelope names such as alien.worlds and mycoll.wam pass unchanged. Every other value keeps the existing percent-encoding.

Validation

yarn check-types, yarn lint, and yarn test pass. The new tests drive '', ., .., null, and undefined through a representative reader and assert the fetch stub records no call, sweep every path-building method with .., and pin that a dotted name still reaches the recorded URL unchanged.

…ling route

Every path-building read percent-encoded its id, but encodeURIComponent
leaves dots alone, so an id of "." or ".." survived into the path and the URL
parser inside fetch collapsed it onto the route above, and an empty id turned
a single-row route into its list. The caller then read rows it never asked
for instead of seeing a failure. Those values are never an id, a name, or an
account, so the path builder now throws before the request, naming the field.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens AtomicMarketApi Explorer URL construction by rejecting path-segment values that can be normalized by the URL parser ('', ., ..), preventing requests from silently landing on sibling/list routes and returning unintended data.

Changes:

  • Introduces a centralized encodeSegment helper that throws on empty and dot-segment values (and on missing values) before a network request is made.
  • Updates all Explorer methods that embed caller-supplied values into URL path segments to use encodeSegment instead of encodeURIComponent.
  • Adds targeted tests ensuring invalid segment values do not reach the fetch stub and that dotted Antelope names remain unchanged.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/API/Explorer/index.ts Adds encodeSegment and applies it to all path-segment-building Explorer methods to prevent dot-segment path rewriting.
test/path-segments.test.ts Adds regression tests covering empty/dot/dot-dot/missing values and a sweep across all affected path-building methods.
README.md Documents the 2.4.1 bug fix behavior change in the changelog section.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@robrigo
robrigo marked this pull request as ready for review August 17, 2026 22:51
@robrigo
robrigo merged commit 2991873 into main Aug 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants