UNPKG

eslint-plugin-i18next

Version:
11 lines (10 loc) 335 B
module.exports = function generateFullMatchRegExp(source) { if (source instanceof RegExp) { return source; } if (typeof source !== 'string') { throw new Error('generateFullMatchRegExp: expect string but get', source); } // allow dot ahead return new RegExp(`(^|\\.)${source}${source.endsWith('$') ? '' : '$'}`); };