Skip to content

Fix - Align MessageProcessor path normalization with DataContext semantics#958

Open
everforge wants to merge 2 commits intogoogle:mainfrom
everforge:fix/web-core-resolve-path-normalization
Open

Fix - Align MessageProcessor path normalization with DataContext semantics#958
everforge wants to merge 2 commits intogoogle:mainfrom
everforge:fix/web-core-resolve-path-normalization

Conversation

@everforge
Copy link

Description

This PR aligns MessageProcessor.resolvePath() behavior with existing DataContext path semantics in web_core, improving consistency for relative-path handling.
It adds explicit normalization for "", ".", and "./..." inputs so paths resolve predictably and avoid malformed outputs such as trailing /..

Before: some relative edge cases produced inconsistent results depending on code path.
After: path resolution is consistent across processor/context logic and covered by regression tests.

Fixes: N/A (no tracked issue).

Pre-launch Checklist

If you need help, consider asking for advice on the discussion board.

@google-cla
Copy link

google-cla bot commented Mar 24, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the resolvePath function to correctly handle relative paths like . and ./, as well as empty strings, resolving them against a given context path or the root. Corresponding test cases have been added. The reviewer suggests adding further test cases for resolvePath("./", "/bar") and resolvePath("./") to ensure comprehensive coverage of . and ./ edge cases.

assert.strictEqual(processor.resolvePath("", "/bar"), "/bar");
assert.strictEqual(processor.resolvePath(".", "/bar/"), "/bar");
assert.strictEqual(processor.resolvePath("foo"), "/foo");
assert.strictEqual(processor.resolvePath("."), "/");
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The PR description explicitly mentions handling "./..." inputs. While "./foo" is covered, adding a test case for resolvePath("./", "/bar") and resolvePath("./") would ensure complete coverage for the "./" edge case, which currently resolves to the context path (or root) without a trailing slash if the context path doesn't have one, or with a trailing slash if it does.

    assert.strictEqual(processor.resolvePath("."), "/");
    assert.strictEqual(processor.resolvePath("./", "/bar"), "/bar/");
    assert.strictEqual(processor.resolvePath("./"), "/");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant