UNPKG

docsify

Version:

A magical documentation generator.

18 lines (15 loc) 527 B
/** * Adds beginning of input (^) and end of input ($) assertions if needed into a regex string * @param {string} matcher the string to match * @returns {string} */ export function makeExactMatcher(matcher) { const matcherWithBeginningOfInput = matcher.startsWith('^') ? matcher : `^${matcher}`; const matcherWithBeginningAndEndOfInput = matcherWithBeginningOfInput.endsWith('$') ? matcherWithBeginningOfInput : `${matcherWithBeginningOfInput}$`; return matcherWithBeginningAndEndOfInput; }