fastmcp 4.22.5 → 4.22.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  cancelResponseBody
3
- } from "./chunk-XPKMA7DH.js";
3
+ } from "./chunk-ISYL7EKR.js";
4
4
  import {
5
5
  strictInputSchema
6
6
  } from "./chunk-UMDUIBFW.js";
@@ -1306,7 +1306,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1306
1306
  const uriTemplate = parseURITemplate(
1307
1307
  resourceTemplate.uriTemplate
1308
1308
  );
1309
- const match = uriTemplate.fromUri(request.params.uri);
1309
+ const match = matchUriTemplate(uriTemplate, request.params.uri);
1310
1310
  if (!match) {
1311
1311
  continue;
1312
1312
  }
@@ -1670,6 +1670,20 @@ function convertObjectToSnakeCase(obj) {
1670
1670
  function joinPaths(basePath, path) {
1671
1671
  return `${basePath}${normalizePath(path)}`;
1672
1672
  }
1673
+ function matchUriTemplate(template, uri) {
1674
+ const match = template.fromUri(uri);
1675
+ if (!match) {
1676
+ return void 0;
1677
+ }
1678
+ const checksQuery = !/\{[?&]/.test(template.template);
1679
+ const checksFragment = !template.template.includes("{#");
1680
+ const shape = (value) => [
1681
+ value.split(/[?#]/, 1)[0].split("/").length,
1682
+ checksQuery && value.includes("?"),
1683
+ checksFragment && value.includes("#")
1684
+ ].join();
1685
+ return shape(template.fill(match)) === shape(uri) ? match : void 0;
1686
+ }
1673
1687
  function normalizeBasePath(path) {
1674
1688
  if (!path || path === "/") {
1675
1689
  return "";
@@ -1950,7 +1964,7 @@ var FastMCP = class extends FastMCPEventEmitter {
1950
1964
  }
1951
1965
  for (const template of this.#resourcesTemplates) {
1952
1966
  const parsedTemplate = parseURITemplate(template.uriTemplate);
1953
- const params = parsedTemplate.fromUri(uri);
1967
+ const params = matchUriTemplate(parsedTemplate, uri);
1954
1968
  if (!params) {
1955
1969
  continue;
1956
1970
  }
@@ -3052,4 +3066,4 @@ export {
3052
3066
  FastMCPSession,
3053
3067
  FastMCP
3054
3068
  };
3055
- //# sourceMappingURL=chunk-A6QGY7T7.js.map
3069
+ //# sourceMappingURL=chunk-OAM6AYJY.js.map