MCPcopy
hub / github.com/cita-777/metapi / parseTokenRouteRegexPattern

Function parseTokenRouteRegexPattern

src/shared/tokenRoutePatterns.js:473–492  ·  view source on GitHub ↗
(pattern)

Source from the content-addressed store, hash-verified

471}
472
473export function parseTokenRouteRegexPattern(pattern) {
474 if (!isTokenRouteRegexPattern(pattern)) {
475 return { regex: null, error: null };
476 }
477 const body = pattern.trim().slice(3).trim();
478 if (!body) {
479 return { regex: null, error: 're: 后缺少正则表达式' };
480 }
481 if (!isSafeRegexPatternBody(body)) {
482 return { regex: null, error: '出于安全原因不支持该正则表达式' };
483 }
484 try {
485 return {
486 regex: compileSafeRegexPattern(body),
487 error: null,
488 };
489 } catch (error) {
490 return { regex: null, error: error?.message || '无效正则' };
491 }
492}
493
494export function matchesTokenRouteModelPattern(model, pattern) {
495 const normalized = (pattern || '').trim();

Callers 4

parseRegexModelPatternFunction · 0.90
parseRegexModelPatternFunction · 0.90

Calls 3

isTokenRouteRegexPatternFunction · 0.85
isSafeRegexPatternBodyFunction · 0.85
compileSafeRegexPatternFunction · 0.85

Tested by

no test coverage detected