HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/share/nodejs/fast-glob/out/providers/matchers/partial.spec.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const settings_1 = require("../../settings");
const partial_1 = require("./partial");
function getMatcher(patterns, options = {}) {
    return new partial_1.default(patterns, new settings_1.default(), options);
}
function assertMatch(patterns, filepath) {
    const matcher = getMatcher(patterns);
    assert.ok(matcher.match(filepath), `Path "${filepath}" should match: ${patterns}`);
}
function assertNotMatch(patterns, filepath) {
    const matcher = getMatcher(patterns);
    assert.ok(!matcher.match(filepath), `Path "${filepath}" should do not match: ${patterns}`);
}
describe('Providers → Matchers → Partial', () => {
    describe('.match', () => {
        it('should handle patterns with globstar', () => {
            assertMatch(['**'], 'a');
            assertMatch(['**'], './a');
            assertMatch(['**/a'], 'a');
            assertMatch(['**/a'], 'b/a');
            assertMatch(['a/**'], 'a/b');
            assertNotMatch(['a/**'], 'b');
        });
        it('should do not match the latest segment', () => {
            assertMatch(['b/*'], 'b');
            assertNotMatch(['*'], 'a');
            assertNotMatch(['a/*'], 'a/b');
        });
        it('should trying to match all patterns', () => {
            assertMatch(['a/*', 'b/*'], 'b');
            assertMatch(['non-match/b/c', 'a/*/c'], 'a/b');
            assertNotMatch(['non-match/d/c', 'a/b/c'], 'a/d');
        });
        it('should match a static segment', () => {
            assertMatch(['a/b'], 'a');
            assertNotMatch(['b/b'], 'a');
        });
        it('should match a dynamic segment', () => {
            assertMatch(['*/b'], 'a');
            assertMatch(['{a,b}/*'], 'a');
            assertNotMatch(['{a,b}/*'], 'c');
        });
    });
});