Skip to main content
Glama
Apache 2.0
727
2,085
  • Apple
import { describe, expect, test } from 'vitest'; import { matchUriTemplate } from './util.js'; describe('matchUriTemplate', () => { test('should match a URI template and extract parameters', () => { const uri = 'http://example.com/users/123'; const templates = ['http://example.com/users/{userId}']; const result = matchUriTemplate(uri, templates); expect(result).toEqual({ uri: 'http://example.com/users/{userId}', params: { userId: '123' }, }); }); test('should return undefined if no template matches', () => { const uri = 'http://example.com/users/123'; const templates = ['http://example.com/posts/{postId}']; const result = matchUriTemplate(uri, templates); expect(result).toBeUndefined(); }); test('should match the correct template when multiple templates are provided', () => { const uri = 'http://example.com/posts/456/comments/789'; const templates = [ 'http://example.com/users/{userId}', 'http://example.com/posts/{postId}/comments/{commentId}', ]; const result = matchUriTemplate(uri, templates); expect(result).toEqual({ uri: 'http://example.com/posts/{postId}/comments/{commentId}', params: { postId: '456', commentId: '789' }, }); }); test('should handle templates with multiple parameters', () => { const uri = 'http://example.com/users/123/orders/456'; const templates = ['http://example.com/users/{userId}/orders/{orderId}']; const result = matchUriTemplate(uri, templates); expect(result).toEqual({ uri: 'http://example.com/users/{userId}/orders/{orderId}', params: { userId: '123', orderId: '456' }, }); }); test('should return undefined if the URI segments do not match the template segments', () => { const uri = 'http://example.com/users/123/orders'; const templates = ['http://example.com/users/{userId}/orders/{orderId}']; const result = matchUriTemplate(uri, templates); expect(result).toBeUndefined(); }); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/supabase-community/mcp-supabase'

If you have feedback or need assistance with the MCP directory API, please join our Discord server