Fix - Align MessageProcessor path normalization with DataContext semantics#958
Fix - Align MessageProcessor path normalization with DataContext semantics#958everforge wants to merge 2 commits intogoogle:mainfrom
Conversation
|
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. |
There was a problem hiding this comment.
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("."), "/"); |
There was a problem hiding this comment.
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("./"), "/");
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.