MCPcopy Index your code
hub / github.com/nodejs/node / matchOne

Method matchOne

deps/minimatch/index.js:1564–1594  ·  view source on GitHub ↗
(file, pattern, partial = false)

Source from the content-addressed store, hash-verified

1562 // out of pattern, then that's fine, as long as all
1563 // the parts match.
1564 matchOne(file, pattern, partial = false) {
1565 let fileStartIndex = 0;
1566 let patternStartIndex = 0;
1567 if (this.isWindows) {
1568 const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
1569 const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
1570 const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
1571 const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
1572 const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
1573 const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
1574 if (typeof fdi === "number" && typeof pdi === "number") {
1575 const [fd, pd] = [
1576 file[fdi],
1577 pattern[pdi]
1578 ];
1579 if (fd.toLowerCase() === pd.toLowerCase()) {
1580 pattern[pdi] = fd;
1581 patternStartIndex = pdi;
1582 fileStartIndex = fdi;
1583 }
1584 }
1585 }
1586 const { optimizationLevel = 1 } = this.options;
1587 if (optimizationLevel >= 2) {
1588 file = this.levelTwoFileOptimize(file);
1589 }
1590 if (pattern.includes(exports.GLOBSTAR)) {
1591 return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
1592 }
1593 return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
1594 }
1595 #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
1596 const firstgs = pattern.indexOf(exports.GLOBSTAR, patternIndex);
1597 const lastgs = pattern.lastIndexOf(exports.GLOBSTAR);

Callers 1

matchMethod · 0.80

Calls 5

levelTwoFileOptimizeMethod · 0.80
includesMethod · 0.80
#matchGlobstarMethod · 0.80
#matchOneMethod · 0.80
testMethod · 0.45

Tested by

no test coverage detected