From 9bdb95c9e34cef640534e5e5a1e2225a80442000 Mon Sep 17 00:00:00 2001 From: HelenHuang <LinHuang@pollex.com.tw> Date: 星期四, 09 六月 2022 15:48:15 +0800 Subject: [PATCH] TODO#139894 [ footer -最下方說明與保經代合作 ] 文案修改 --- PAMapp/node_modules/ignore/index.js | 54 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 30 insertions(+), 24 deletions(-) diff --git a/PAMapp/node_modules/ignore/index.js b/PAMapp/node_modules/ignore/index.js index 9dcee20..d935eb1 100644 --- a/PAMapp/node_modules/ignore/index.js +++ b/PAMapp/node_modules/ignore/index.js @@ -30,6 +30,8 @@ const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g +const RETURN_FALSE = () => false + // Sanitize the range of a regular expression // The cases are complicated, see test cases for details const sanitizeRange = range => range.replace( @@ -288,22 +290,18 @@ const regexCache = Object.create(null) // @param {pattern} -const makeRegex = (pattern, negative, ignorecase) => { - const r = regexCache[pattern] - if (r) { - return r +const makeRegex = (pattern, ignoreCase) => { + let source = regexCache[pattern] + + if (!source) { + source = REPLACERS.reduce( + (prev, current) => prev.replace(current[0], current[1].bind(pattern)), + pattern + ) + regexCache[pattern] = source } - // const replacers = negative - // ? NEGATIVE_REPLACERS - // : POSITIVE_REPLACERS - - const source = REPLACERS.reduce( - (prev, current) => prev.replace(current[0], current[1].bind(pattern)), - pattern - ) - - return regexCache[pattern] = ignorecase + return ignoreCase ? new RegExp(source, 'i') : new RegExp(source) } @@ -334,7 +332,7 @@ } } -const createRule = (pattern, ignorecase) => { +const createRule = (pattern, ignoreCase) => { const origin = pattern let negative = false @@ -352,7 +350,7 @@ // > begin with a hash. .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#') - const regex = makeRegex(pattern, negative, ignorecase) + const regex = makeRegex(pattern, ignoreCase) return new IgnoreRule( origin, @@ -398,11 +396,15 @@ class Ignore { constructor ({ - ignorecase = true + ignorecase = true, + ignoreCase = ignorecase, + allowRelativePaths = false } = {}) { - this._rules = [] - this._ignorecase = ignorecase define(this, KEY_IGNORE, true) + + this._rules = [] + this._ignoreCase = ignoreCase + this._allowRelativePaths = allowRelativePaths this._initCache() } @@ -420,7 +422,7 @@ } if (checkPattern(pattern)) { - const rule = createRule(pattern, this._ignorecase) + const rule = createRule(pattern, this._ignoreCase) this._added = true this._rules.push(rule) } @@ -499,7 +501,13 @@ // Supports nullable path && checkPath.convert(originalPath) - checkPath(path, originalPath, throwError) + checkPath( + path, + originalPath, + this._allowRelativePaths + ? RETURN_FALSE + : throwError + ) return this._t(path, cache, checkUnignored, slices) } @@ -557,10 +565,8 @@ const factory = options => new Ignore(options) -const returnFalse = () => false - const isPathValid = path => - checkPath(path && checkPath.convert(path), path, returnFalse) + checkPath(path && checkPath.convert(path), path, RETURN_FALSE) factory.isPathValid = isPathValid -- Gitblit v1.8.0