INTER-2499 fix: url encode path parameters (api-v3) - #285
Conversation
Backport of #282 to the api-v3 line. Refs INTER-2499
🦋 Changeset detectedLatest commit: bbed302 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Coverage report
Test suite run success137 tests passing in 12 suites. Report generated by 🧪jest coverage report action from bbed302 Show full coverage report
|
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues were identified.
Pull request overview
Fixes API v3 path parameter handling by encoding values and rejecting dot segments that could normalize to unintended endpoints.
Changes:
- Encodes path parameters safely.
- Rejects
.and..values. - Adds unit and wire-level tests.
- Documents the patch release.
File summaries
| File | Description |
|---|---|
tests/unit-tests/urlUtilsTests.spec.ts |
Tests encoding and invalid inputs. |
tests/mocked-responses-tests/pathParamEncodingTests.spec.ts |
Verifies exact request URLs and hosts. |
src/urlUtils.ts |
Implements path encoding and validation. |
.changeset/encode-path-parameters.md |
Records the patch release. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mcnulty-fp
left a comment
There was a problem hiding this comment.
Just one minor thing but other than that, looks good!
🚀 Following releases will be created using changesets from this PR:@fingerprintjs/fingerprintjs-pro-server-api@6.13.1Patch Changes
|
Fixes INTER-2499 on the
api-v3line. Backport of #282. Path params were interpolated raw, sogetEvent('../events/search')requested/events/search.encodeURIComponentingetRequestPath, the choke point forgetEvent,updateEvent,getVisits(and the deprecatedgetVisitorHistory) anddeleteVisitorData..and..with aTypeError.fetchURL and host.Real IDs are
encodeURIComponentno-ops, so nothing changes on the wire for legitimate traffic.Differences from #282
getRequestPathon this branch keeps its generic signature and has noapiVersionprefix, so the normalization guard comparesurl.pathnameagainst the path as-is.causeassert the type and the message separately —toThrow(new TypeError(...))comparescausetoo.getVisits, which does not exist on v4.Discussion point: why
.and..throw instead of being encodedThe URL Standard treats
%2eas a dot when matching dot-path segments, sonew URL()drops the segment for..and%2E%2Ealike. A literal dot segment is unrepresentable, so throwing is the only option.