UNPKG

url-builder-mcp

Version:

URL Builder MCP Server - Professional URL construction with intelligent parameter handling for Claude Desktop

55 lines (42 loc) 1.87 kB
#!/usr/bin/env node /** * Smart script to fix tests that need to disable UTM tracking * Uses DRY principles to update test expectations intelligently */ const fs = require('fs'); const path = require('path'); function fixTestFile(filePath) { let content = fs.readFileSync(filePath, 'utf8'); // Pattern 1: buildInternalUrl calls without options that expect no UTM content = content.replace( /const url = buildInternalUrl\(params\);\s*expect\(url\)\.toBe\('([^']+)'\);/g, "const url = buildInternalUrl(params, { addUtmTracking: false });\n expect(url).toBe('$1');" ); // Pattern 2: buildCompleteUrl calls without options that expect no UTM content = content.replace( /const url = buildCompleteUrl\('([^']+)', params\);\s*expect\(url\)\.toBe\('([^']+)'\);/g, "const url = buildCompleteUrl('$1', params, { addUtmTracking: false });\n expect(url).toBe('$2');" ); // Pattern 3: buildInternalUrl with useBaseDomain option content = content.replace( /const url = buildInternalUrl\(params, \{ useBaseDomain: true \}\);\s*expect\(url\)\.toBe\('([^']+)'\);/g, "const url = buildInternalUrl(params, { useBaseDomain: true, addUtmTracking: false });\n expect(url).toBe('$1');" ); // Pattern 4: buildCompleteUrl calls without params that expect no UTM content = content.replace( /const url = buildCompleteUrl\('([^']+)'\);\s*expect\(url\)\.toBe\('([^']+)'\);/g, "const url = buildCompleteUrl('$1', undefined, { addUtmTracking: false });\n expect(url).toBe('$2');" ); fs.writeFileSync(filePath, content, 'utf8'); } function main() { const testFile = path.join(__dirname, '..', 'src', '__tests__', 'urlBuilder.test.ts'); if (fs.existsSync(testFile)) { fixTestFile(testFile); } } // Run if called directly if (require.main === module) { main(); } module.exports = { fixTestFile };