ui: Fix handling of MCP resource template parameters (#23117)

* Fix handling of MCP resource template parameters

* Fix formatting for uri-template.test.ts

---------

Co-authored-by: kuba <kuba@laptop.local.net>
This commit is contained in:
kubawoo 2026-05-16 13:25:41 +02:00 committed by GitHub
parent 1428004808
commit b81c2cdd74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -160,7 +160,7 @@ export function expandTemplate(template: string, values: Record<string, string>)
(name: string, i: number) =>
`${encodeURIComponent(name)}=${encodeURIComponent(expandedParts[i])}`
)
.join(URI_TEMPLATE_SEPARATORS.COMMA)
.join(URI_TEMPLATE_SEPARATORS.QUERY_CONTINUATION)
);
case URI_TEMPLATE_OPERATORS.FORM_CONTINUATION:
// Form-style query continuation

View file

@ -107,6 +107,14 @@ describe('expandTemplate', () => {
expect(result).toBe('http://example.com?q=search%20term');
});
it('expands multiple query parameters', () => {
const result = expandTemplate('http://example.com{?q,sort}', {
q: 'search term',
sort: 'descending'
});
expect(result).toBe('http://example.com?q=search%20term&sort=descending');
});
it('keeps static parts unchanged', () => {
const result = expandTemplate('http://example.com/static', {});
expect(result).toBe('http://example.com/static');