index.js
function add(str, {split, last, only}={}) {
        if (only !== 'path') regex += str;
        if (filepath && only !== 'regex') {
            path.regex += (str === '\\/' ? SEP : str);
            if (split) {
                if (last) segment += str;
                if (segment !== '') {
                    if (!flags.includes('g')) segment = `^${segment}$`; // change it 'includes'
                    path.segments.push(new RegExp(segment, flags));
                }
                segment = '';
            } else {
                segment += str;
            }
        }
    }
function add(str, {split, last, only}={}) {
        if (only !== 'path') regex += str;
        if (filepath && only !== 'regex') {
            path.regex += (str === '\\/' ? SEP : str);
            if (split) {
                if (last) segment += str;
                if (segment !== '') {
                    if (!flags.includes('g')) segment = `^${segment}$`; // change it 'includes'
                    path.segments.push(new RegExp(segment, flags));
                }
                segment = '';
            } else {
                segment += str;
            }
        }
    }
function add ( str , { split , last , only } = { } ) { if ( only !== 'path' ) regex += str ; if ( filepath && only !== 'regex' ) { path . regex += ( str === '\\/' ? SEP : str ) ; if ( split ) { if ( last ) segment += str ; if ( segment !== '' ) { if ( ! flags . includes ( 'g' ) ) segment = ` ${ segment } ` ; // change it 'includes' path . segments . push ( new RegExp ( segment , flags ) ) ; } segment = '' ; } else { segment += str ; } } }
Helper function to build string and segments
Helper function to build string and segments