Repository navigation
Fix nested path URI resolution - #974
Qshuai0213 wants to merge 2 commits into
Conversation
|
I pulled this branch ( Here's what I get calling
Under RFC 3986 §5.2.2, a reference with a leading Something narrower might fix #257 without changing absolute-path references: only append when the endpoint has no leading slash, i.e. treat the base as a directory (add a trailing How I testedgit fetch upstream pull/974/head:pr-974
git worktree add ../pr-974 pr-974 && cd ../pr-974
./mvnw -pl mcp-core test -Dtest=UtilsTests # 13/13 pass
# then called Utils.resolveUri(URI.create(base), endpoint) for the rows above
# against mcp-core/target/classes, on this branch and on main (6c0a020b) |
Summary
Fixes #257
Utils.resolveUriincorrectly handled nested base paths — relative endpoints with a leading slash (e.g./api/v1) would replace the base path entirely instead of being appended to it. This affectedHttpClientSseClientTransportandHttpClientStreamableHttpTransportwhen the base URL had a non-root path (e.g.https://example.com/some).Root cause
URI.resolve()follows RFC 3986 §5.2.3: when the relative reference starts with/, it replaces the entire path of the base URI. SoURI.create("https://example.com/some").resolve("/path")yieldshttps://example.com/path, dropping/some.Fix approach
/root→/root/)/api/v1→api/v1)URI.resolve()then performs path concatenation (/root/+api/v1=/root/api/v1), consistent with RFC 3986Testing
./mvnw.cmd -pl mcp-core -Dtest=UtilsTests test./mvnw.cmd -pl mcp-core test