Hermes.URI (hermes_mcp v0.3.6)

URI utilities for handling URL paths consistently.

Summary

Functions

Joins a base URI with a path segment, handling trailing and leading slashes correctly.

Joins a base URI with multiple path segments, handling trailing and leading slashes correctly.

Functions

join_path(base_uri, path)

@spec join_path(URI.t(), String.t()) :: URI.t()

Joins a base URI with a path segment, handling trailing and leading slashes correctly.

Examples

iex> Hermes.URI.join_path(URI.new!("http://localhost:8000"), "/mcp")
%URI{scheme: "http", host: "localhost", port: 8000, path: "/mcp"}

iex> Hermes.URI.join_path(URI.new!("http://localhost:8000/"), "/mcp")
%URI{scheme: "http", host: "localhost", port: 8000, path: "/mcp"}

iex> Hermes.URI.join_path(URI.new!("http://localhost:8000/api"), "/mcp")
%URI{scheme: "http", host: "localhost", port: 8000, path: "/api/mcp"}

join_paths(base_uri, paths)

@spec join_paths(URI.t(), [String.t()]) :: URI.t()

Joins a base URI with multiple path segments, handling trailing and leading slashes correctly.