pax_global_header00006660000000000000000000000064134054701760014521gustar00rootroot0000000000000052 comment=9f6521b4a97664b2270b01de1f44a371a425e298 globrex-0.1.2/000077500000000000000000000000001340547017600131635ustar00rootroot00000000000000globrex-0.1.2/.gitignore000066400000000000000000000000271340547017600151520ustar00rootroot00000000000000node_modules .DS_Store globrex-0.1.2/.travis.yml000066400000000000000000000000411340547017600152670ustar00rootroot00000000000000language: node_js node_js: - 8 globrex-0.1.2/appveyor.yml000066400000000000000000000003361340547017600155550ustar00rootroot00000000000000environment: nodejs_version: "8" install: - ps: Install-Product node $env:nodejs_version - npm install --global npm@latest - npm install test_script: - node --version - npm --version - npm test build: off globrex-0.1.2/globrex.png000066400000000000000000000541261340547017600153430ustar00rootroot00000000000000PNG  IHDR=MJa IDATxymmt+QD"Z*2TRI$Mj-i`DդhI"Ayػopgs>p{g`f`̘1: "?p%'GO+""n4Mw*GOp~x>)"y .N LWxր""2T7O@ ťMt;7RΆ@y}Oqgj3%/TRuEDdĨ@o-P>܂ S.Cu/Ń@..xqD$McJ>768 w*ЇWp+Z "৔aw84(8p+HKC8KDDd**Лp T([yr&>WN6i%ѧ|EDd@o-P>'Z$`{͂ c)>g@o,DQpq>`]3pupq% "ҳ7X~\_苈HKA>ՀsLA`%묃p .X - ONx(@ .^bc&T\oDDDliyAM?;/!+Ppq_vSP>}\\":8V .naDDDd\d w_eBKpq)gw;7?Paq L̈HCFZ>G9(Squ\oV< cOųV9s\\1R~lSd :À/X>[i{n \\\G%Apq:%-^r p4pO Fŏ'xKԁPxu < ,Squi iH|* lc3(Ji 8XpKpq .J9;z0uI|:0R.ҟ۬LrCX .\xy)ςKpq whu%ť8uIj@DDd@NY\|#~f..%ů0YI7LV"""Hpu ՁW|in5_;;8Rŗ8 :$η ""2T |*amgPߔՁKg8O pvpq^iWTnBDDd@>'Xh[pq5- Zj)P . 80rG18:ȰR.2\NѦ⛀_NqsH.. neezÔGHT 4JgweYH_`ZU~ Ҩm]`_2|*!""2T s%8WX83* uxu\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:ڪaؔE;.xu$G$cJeIcdYz>Ϯ<&o'vJ1$9 ohÊӽSKr "%n)j$KI(WIO/`uc9cJ :ɭpl$?HnS͗bxRJVL$/H\xsdAٳgs}-i)]:?R~.F[zϔ×/Jݔ_6}Vڪ+?[iF)oNr 䦯_q5d{hJ~L^ +'+ |8[RV,Cm%6aS^9Z4aФtKVJmvCSJyQ g][uszRmGWtxc9_= \ lUwٻE$glo|5}mPڪ~滭5}ܙۆ;-_JQ}V8ܾ<=`vg;nM_x[uKrPJk&i?NWawyreVCT)/%HzE'\VݍS_Orf?2}|$_SSƗS΄'gS[uwHي8c~scÖSr{'rQJQOM0=` ^Rt;w%PH O`iN)[ykOrz75}bmmJ2gxyR]`}MJuOTo|3֒fꎜ0ޜ+`U$yEI~-mj@mvy&A1IY tX 𾦯3SlUO%yLMmՍ@{ıwU3X5 Ě~]g $q8Μ3X'y+}$yI8/L[u$"\5}b^DZYAIׯ<+鿖mq蹞$}FCB_7{۪"y"ZI5C\ϬSt3>(im-g9IqVM_v 'A_OO3=.ɩV݁) M`%Iy=-_UJdjHء< A_M__I;C'&D[uohI>jNnZ[5`]Q'k#m1ɧ?ڄv$oL5} m]=%9%'HrLW6,m O`% zUwX$w o$\ʊ$^jIiN_J;$s'=Iڪ{Hc[^M_7D`#O򷤚~oR mtg'X$KOR=dSߟ{"c/_Ĺ1wx! mU$R$lsO(A+ 1 && // multiple "*"'s (prevChar === '/' || prevChar === undefined) && // from the start of the segment (nextChar === '/' || nextChar === undefined); // to the end of the segment if (isGlobstar) { // it's a globstar, so match zero or more path segments add(GLOBSTAR, {only:'regex'}); add(GLOBSTAR_SEGMENT, {only:'path', last:true, split:true}); i++; // move over the "/" } else { // it's not a globstar, so only match one path segment add(WILDCARD, {only:'regex'}); add(WILDCARD_SEGMENT, {only:'path'}); } } continue; } add(c); } // When regexp 'g' flag is specified don't // constrain the regular expression with ^ & $ if (!flags.includes('g')) { regex = `^${regex}$`; segment = `^${segment}$`; if (filepath) path.regex = `^${path.regex}$`; } const result = {regex: new RegExp(regex, flags)}; // Push the last segment if (filepath) { path.segments.push(new RegExp(segment, flags)); path.regex = new RegExp(path.regex, flags); path.globstar = new RegExp(!flags.includes('g') ? `^${GLOBSTAR_SEGMENT}$` : GLOBSTAR_SEGMENT, flags); result.path = path; } return result; } module.exports = globrex; globrex-0.1.2/license000066400000000000000000000020671340547017600145350ustar00rootroot00000000000000MIT License Copyright (c) 2018 Terkel Gjervig Nielsen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. globrex-0.1.2/package.json000066400000000000000000000010611340547017600154470ustar00rootroot00000000000000{ "name": "globrex", "version": "0.1.2", "description": "Glob to regular expression with support for extended globs", "main": "index.js", "author": "Terkel Gjervig", "license": "MIT", "repository": { "type": "git", "url": "https://github.com/terkelg/globrex" }, "files": [ "index.js" ], "keywords": [ "glob", "regex", "regexp", "parser", "glob2regx", "compiler" ], "scripts": { "test": "tape test/*.js | tap-spec" }, "devDependencies": { "tap-spec": "^4.1.1", "tape": "^4.8.0" } } globrex-0.1.2/readme.md000066400000000000000000000110171340547017600147420ustar00rootroot00000000000000
globrex

globrex

Simple but powerful glob to regular expression compiler.

## Install ``` npm install globrex --save ``` ## Core Features - 💪 **extended globbing:** transform advance `ExtGlob` features - 📦 **simple**: no dependencies - 🛣️ **paths**: split paths into multiple `RegExp` segments ## Usage ```js const globrex = require('globrex'); const result = globrex('p*uck') // => { regex: /^p.*uck$/, string: '^p.*uck$', segments: [ /^p.*uck$/ ] } result.regex.test('pluck'); // true ``` ## API ### globrex(glob, options) Type: `function`
Returns: `Object` Transform globs intp regular expressions. Returns object with the following properties: #### regex Type: `RegExp` JavaScript `RegExp` instance. > **Note**: Read more about how to use [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) on MDN. #### path This property only exists if the option `filepath` is true. > **Note:** `filepath` is `false` by default #### path.segments Type: `Array` Array of `RegExp` instances seperated by `/`. This can be usable when working with file paths or urls. Example array could be: ```js [ /^foo$/, /^bar$/, /^([^\/]*)$/, '^baz\\.(md|js|txt)$' ] ``` #### path.regex Type: `RegExp` JavaScript `RegExp` instance build for testign against paths. The regex have different path seperators depending on host OS. ### glob Type: `String` Glob string to transform. ### options.extended Type: `Boolean`
Default: `false` Enable all advanced features from `extglob`. Matching so called "extended" globs pattern like single character matching, matching ranges of characters, group matching, etc. > **Note**: Interprets `[a-d]` as `[abcd]`. To match a literal `-`, include it as first or last character. ### options.globstar Type: `Boolean`
Default: `false` When globstar is `false` globs like `'/foo/*'` are transformed to the following `'^\/foo\/.*$'` which will match any string beginning with `'/foo/'`. When the globstar option is `true`, the same `'/foo/*'` glob is transformed to `'^\/foo\/[^/]*$'` which will match any string beginning with `'/foo/'` that **does not have** a `'/'` to the right of it. `'/foo/*'` will match: `'/foo/bar'`, `'/foo/bar.txt'` but not `'/foo/bar/baz'` or `'/foo/bar/baz.txt'`. > **Note**: When globstar is `true`, `'/foo/**'` is equivelant to `'/foo/*'` when globstar is `false`. ### options.strict Type: `Boolean`
Default: `false` Be forgiving about mutiple slashes, like `///` and make everything after the first `/` optional. This is how bash glob works. ### options.flags Type: `String`
Default: `''` RegExp flags (e.g. `'i'` ) to pass to the RegExp constructor. ### options.filepath Type: `Boolean`
Default: `false` Parse input strings as it was a file path for special path related features. This feature only makes sense if the input is a POSIX path like `/foo/bar/hello.js` or URLs. When `true` the returned object will have an additional `path` object. - `segment`: Array containing a `RegExp` object for each path segment. - `regex`: OS specific file path `RegExp`. Path seperator used is based on the operating system. - `globstar`: Regex string used to test for globstars. > **Note: Please only use forward-slashes in file path glob expressions** > Though windows uses either `/` or `\` as its path separator, only `/` > characters are used by this glob implementation. You must use > forward-slashes **only** in glob expressions. Back-slashes will always > be interpreted as escape characters, not path separators. ## References Learn more about advanced globbing here - [mywiki.wooledge.org/glob](http://mywiki.wooledge.org/glob) - [linuxjournal](http://www.linuxjournal.com/content/bash-extended-globbing) ## License MIT © [Terkel Gjervig](https://terkel.com) globrex-0.1.2/test/000077500000000000000000000000001340547017600141425ustar00rootroot00000000000000globrex-0.1.2/test/helpers/000077500000000000000000000000001340547017600156045ustar00rootroot00000000000000globrex-0.1.2/test/helpers/index.js000066400000000000000000000015411340547017600172520ustar00rootroot00000000000000const globrex = require('../../'); const isWin = process.platform === 'win32'; function match(glob, strUnix, strWin, opts = {}) { if (typeof strWin === 'object') { opts = strWin; strWin = false; } let res = globrex(glob, opts); return res.regex.test(isWin && strWin ? strWin : strUnix); } function matchRegex(t, pattern, ifUnix, ifWin, opts) { const res = globrex(pattern, opts); const {regex} = (opts.filepath ? res.path : res); t.is(regex.toString(), isWin ? ifWin : ifUnix, '~> regex matches expectant'); return res; } function matchSegments(t, pattern, ifUnix, ifWin, opts) { const res = globrex(pattern, {filepath:true, ...opts}); const str = res.path.segments.join(' '); const exp = (isWin ? ifWin : ifUnix).join(' '); t.is(str, exp); return res; } module.exports = { match, matchRegex, matchSegments }; globrex-0.1.2/test/index.js000066400000000000000000000502031340547017600156070ustar00rootroot00000000000000const fs = require('fs'); const test = require('tape'); const globrex = require('../'); const {match, matchRegex, matchSegments} = require('./helpers'); test('globrex: standard', t => { t.plan(3); let res = globrex('*.js'); t.equal(typeof globrex, 'function', 'consturctor is a typeof function'); t.equal(res instanceof Object, true, 'returns object'); t.equal(res.regex.toString(), '/^.*\\.js$/', 'returns regex object'); }); test('globrex: Standard * matching', t => { t.plan(12); t.equal(match('*', 'foo'), true, 'match everything'); t.equal(match('*', 'foo', { flags:'g' }), true, 'match everything'); t.equal(match('f*', 'foo'), true, 'match the end'); t.equal(match('f*', 'foo', { flags:'g' }), true, 'match the end'); t.equal(match('*o', 'foo'), true, 'match the start'); t.equal(match('*o', 'foo', { flags:'g' }), true, 'match the start'); t.equal(match('f*uck', 'firetruck'), true, 'match the middle'); t.equal(match('f*uck', 'firetruck', { flags:'g' }), true, 'match the middle'); t.equal(match('uc', 'firetruck'), false, 'do not match without g'); t.equal(match('uc', 'firetruck', { flags:'g' }), true, 'match anywhere with RegExp "g"'); t.equal(match('f*uck', 'fuck'), true, 'match zero characters'); t.equal(match('f*uck', 'fuck', { flags:'g' }), true, 'match zero characters'); }); test('globrex: advance * matching', t => { t.plan(21); t.equal(match('*.min.js', 'http://example.com/jquery.min.js', { globstar:false }), true, 'complex match'); t.equal(match('*.min.*', 'http://example.com/jquery.min.js', { globstar:false }), true, 'complex match'); t.equal(match('*/js/*.js', 'http://example.com/js/jquery.min.js', { globstar:false }), true, 'complex match'); t.equal(match('*.min.*', 'http://example.com/jquery.min.js', { flags:'g' }), true, 'complex match global'); t.equal(match('*.min.js', 'http://example.com/jquery.min.js', { flags:'g' }), true, 'complex match global'); t.equal(match('*/js/*.js', 'http://example.com/js/jquery.min.js', { flags:'g' }), true, 'complex match global'); const str = '\\/$^+?.()=!|{},[].*'; t.equal(match(str, str), true, 'battle test complex string - strict'); t.equal(match(str, str, { flags:'g' }), true, 'battle test complex string - strict'); t.equal(match('.min.', 'http://example.com/jquery.min.js'), false, 'matches without/with using RegExp "g"'); t.equal(match('*.min.*', 'http://example.com/jquery.min.js'), true, 'matches without/with using RegExp "g"'); t.equal(match('.min.', 'http://example.com/jquery.min.js', { flags:'g' }), true, 'matches without/with using RegExp "g"'); t.equal(match('http:', 'http://example.com/jquery.min.js'), false, 'matches without/with using RegExp "g"'); t.equal(match('http:*', 'http://example.com/jquery.min.js'), true, 'matches without/with using RegExp "g"'); t.equal(match('http:', 'http://example.com/jquery.min.js', { flags:'g' }), true, 'matches without/with using RegExp "g"'); t.equal(match('min.js', 'http://example.com/jquery.min.js'), false, 'matches without/with using RegExp "g"'); t.equal(match('*.min.js', 'http://example.com/jquery.min.js'), true, 'matches without/with using RegExp "g"'); t.equal(match('min.js', 'http://example.com/jquery.min.js', { flags:'g' }), true, 'matches without/with using RegExp "g"'); t.equal(match('min', 'http://example.com/jquery.min.js', { flags:'g' }), true, 'match anywhere (globally) using RegExp "g"'); t.equal(match('/js/', 'http://example.com/js/jquery.min.js', { flags:'g' }), true, 'match anywhere (globally) using RegExp "g"'); t.equal(match('/js*jq*.js', 'http://example.com/js/jquery.min.js'), false); t.equal(match('/js*jq*.js', 'http://example.com/js/jquery.min.js', { flags:'g' }), true); }); test('globrex: ? match one character, no more and no less', t => { t.plan(15); t.equal(match('f?o', 'foo', { extended:true }), true) t.equal(match('f?o', 'fooo', { extended:true }), false) t.equal(match('f?oo', 'foo', { extended:true }), false) const tester = globstar => { t.equal(match('f?o', 'foo', { extended:true, globstar, flags:'g' }), true) t.equal(match('f?o', 'fooo', { extended:true, globstar, flags:'g' }), true) t.equal(match('f?o?', 'fooo', { extended:true, globstar, flags:'g' }), true) t.equal(match('?fo', 'fooo', { extended:true, globstar, flags:'g' }), false) t.equal(match('f?oo', 'foo', { extended:true, globstar, flags:'g' }), false) t.equal(match('foo?', 'foo', { extended:true, globstar, flags:'g' }), false) } tester(true); tester(false); }); test('globrex: [] match a character range', t => { t.plan(13); t.equal(match('fo[oz]', 'foo', { extended:true }), true); t.equal(match('fo[oz]', 'foz', { extended:true }), true); t.equal(match('fo[oz]', 'fog', { extended:true }), false); t.equal(match('fo[a-z]', 'fob', { extended:true }), true); t.equal(match('fo[a-d]', 'fot', { extended:true }), false); t.equal(match('fo[!tz]', 'fot', { extended:true }), false); t.equal(match('fo[!tz]', 'fob', { extended:true }), true); const tester = globstar => { t.equal(match('fo[oz]', 'foo', { extended:true, globstar, flags:'g' }), true); t.equal(match('fo[oz]', 'foz', { extended:true, globstar, flags:'g' }), true); t.equal(match('fo[oz]', 'fog', { extended:true, globstar, flags:'g' }), false); } tester(true); tester(false); }) test('globrex: [] extended character ranges', t => { t.plan(13); t.equal(match('[[:alnum:]]/bar.txt', 'a/bar.txt', { extended:true }), true); t.equal(match('@([[:alnum:]abc]|11)/bar.txt', '11/bar.txt', { extended:true }), true); t.equal(match('@([[:alnum:]abc]|11)/bar.txt', 'a/bar.txt', { extended:true }), true); t.equal(match('@([[:alnum:]abc]|11)/bar.txt', 'b/bar.txt', { extended:true }), true); t.equal(match('@([[:alnum:]abc]|11)/bar.txt', 'c/bar.txt', { extended:true }), true); t.equal(match('@([[:alnum:]abc]|11)/bar.txt', 'abc/bar.txt', { extended:true }), false); t.equal(match('@([[:alnum:]abc]|11)/bar.txt', '3/bar.txt', { extended:true }), true); t.equal(match('[[:digit:]]/bar.txt', '1/bar.txt', { extended:true }), true); t.equal(match('[[:digit:]b]/bar.txt', 'b/bar.txt', { extended:true }), true); t.equal(match('[![:digit:]b]/bar.txt', 'a/bar.txt', { extended:true }), true); t.equal(match('[[:alnum:]]/bar.txt', '!/bar.txt', { extended:true }), false); t.equal(match('[[:digit:]]/bar.txt', 'a/bar.txt', { extended:true }), false); t.equal(match('[[:digit:]b]/bar.txt', 'a/bar.txt', { extended:true }), false); }); test('globrex: {} match a choice of different substrings', t => { t.plan(12); t.equal(match('foo{bar,baaz}', 'foobaaz', { extended:true }), true); t.equal(match('foo{bar,baaz}', 'foobar', { extended:true }), true); t.equal(match('foo{bar,baaz}', 'foobuzz', { extended:true }), false); t.equal(match('foo{bar,b*z}', 'foobuzz', { extended:true }), true); const tester = globstar => { t.equal(match('foo{bar,baaz}', 'foobaaz', { extended:true, globstar, flag:'g' }), true); t.equal(match('foo{bar,baaz}', 'foobar', { extended:true, globstar, flag:'g' }), true); t.equal(match('foo{bar,baaz}', 'foobuzz', { extended:true, globstar, flag:'g' }), false); t.equal(match('foo{bar,b*z}', 'foobuzz', { extended:true, globstar, flag:'g'}), true); } tester(true); tester(false); }); test('globrex: complex extended matches', t => { t.plan(15) t.equal(match('http://?o[oz].b*z.com/{*.js,*.html}', 'http://foo.baaz.com/jquery.min.js', { extended:true }), true); t.equal(match('http://?o[oz].b*z.com/{*.js,*.html}', 'http://moz.buzz.com/index.html', { extended:true }), true); t.equal(match('http://?o[oz].b*z.com/{*.js,*.html}', 'http://moz.buzz.com/index.htm', { extended:true }), false); t.equal(match('http://?o[oz].b*z.com/{*.js,*.html}', 'http://moz.bar.com/index.html', { extended:true }), false); t.equal(match('http://?o[oz].b*z.com/{*.js,*.html}', 'http://flozz.buzz.com/index.html', { extended:true }), false); const tester = globstar => { t.equal(match('http://?o[oz].b*z.com/{*.js,*.html}', 'http://foo.baaz.com/jquery.min.js', { extended:true, globstar, flags:'g' }), true); t.equal(match('http://?o[oz].b*z.com/{*.js,*.html}', 'http://moz.buzz.com/index.html', { extended:true, globstar, flags:'g' }), true); t.equal(match('http://?o[oz].b*z.com/{*.js,*.html}', 'http://moz.buzz.com/index.htm', { extended:true, globstar, flags:'g' }), false); t.equal(match('http://?o[oz].b*z.com/{*.js,*.html}', 'http://moz.bar.com/index.html', { extended:true, globstar, flags:'g' }), false); t.equal(match('http://?o[oz].b*z.com/{*.js,*.html}', 'http://flozz.buzz.com/index.html', { extended:true, globstar, flags:'g' }), false); } tester(true); tester(false); }); test('globrex: standard globstar', t => { t.plan(6); const tester = globstar => { t.equal(match('http://foo.com/**/{*.js,*.html}', 'http://foo.com/bar/jquery.min.js', { extended: true, globstar, flags: 'g' }), true); t.equal(match('http://foo.com/**/{*.js,*.html}', 'http://foo.com/bar/baz/jquery.min.js', { extended: true, globstar, flags: 'g' }), true); t.equal(match('http://foo.com/**', 'http://foo.com/bar/baz/jquery.min.js', { extended: true, globstar, flags: 'g' }), true); } tester(true); tester(false); }); test('globrex: remaining chars should match themself', t => { t.plan(4); const tester = globstar => { const testExtStr = '\\/$^+.()=!|,.*'; t.equal(match(testExtStr, testExtStr, { extended:true }), true); t.equal(match(testExtStr, testExtStr, { extended:true, globstar, flags: 'g' }), true); } tester(true); tester(false); }); test('globrex: globstar advance testing', t => { t.plan(36); t.equal(match('/foo/*', '/foo/bar.txt', { globstar:true }), true); t.equal(match('/foo/**', '/foo/bar.txt', { globstar:true }), true); t.equal(match('/foo/**', '/foo/bar/baz.txt', { globstar:true }), true); t.equal(match('/foo/**', '/foo/bar/baz.txt', { globstar:true }), true); t.equal(match('/foo/*/*.txt', '/foo/bar/baz.txt', { globstar:true }), true); t.equal(match('/foo/**/*.txt', '/foo/bar/baz.txt', { globstar:true }), true); t.equal(match('/foo/**/*.txt', '/foo/bar/baz/qux.txt', { globstar:true }), true); t.equal(match('/foo/**/bar.txt', '/foo/bar.txt', { globstar:true }), true); t.equal(match('/foo/**/**/bar.txt', '/foo/bar.txt', { globstar:true }), true); t.equal(match('/foo/**/*/baz.txt', '/foo/bar/baz.txt', { globstar:true }), true); t.equal(match('/foo/**/*.txt', '/foo/bar.txt', { globstar:true }), true); t.equal(match('/foo/**/**/*.txt', '/foo/bar.txt', { globstar:true }), true); t.equal(match('/foo/**/*/*.txt', '/foo/bar/baz.txt', { globstar:true }), true); t.equal(match('**/*.txt', '/foo/bar/baz/qux.txt', { globstar:true }), true); t.equal(match('**/foo.txt', 'foo.txt', { globstar:true }), true); t.equal(match('**/*.txt', 'foo.txt', { globstar:true }), true); t.equal(match('/foo/*', '/foo/bar/baz.txt', { globstar:true }), false); t.equal(match('/foo/*.txt', '/foo/bar/baz.txt', { globstar:true }), false); t.equal(match('/foo/*/*.txt', '/foo/bar/baz/qux.txt', { globstar:true }), false); t.equal(match('/foo/*/bar.txt', '/foo/bar.txt', { globstar:true }), false); t.equal(match('/foo/*/*/baz.txt', '/foo/bar/baz.txt', { globstar:true }), false); t.equal(match('/foo/**.txt', '/foo/bar/baz/qux.txt', { globstar:true }), false); t.equal(match('/foo/bar**/*.txt', '/foo/bar/baz/qux.txt', { globstar:true }), false); t.equal(match('/foo/bar**', '/foo/bar/baz.txt', { globstar:true }), false); t.equal(match('**/.txt', '/foo/bar/baz/qux.txt', { globstar:true }), false); t.equal(match('*/*.txt', '/foo/bar/baz/qux.txt', { globstar:true }), false); t.equal(match('*/*.txt', 'foo.txt', { globstar:true }), false); t.equal(match('http://foo.com/*', 'http://foo.com/bar/baz/jquery.min.js', { extended: true, globstar: true }), false); t.equal(match('http://foo.com/*', 'http://foo.com/bar/baz/jquery.min.js', { globstar: true }), false); t.equal(match('http://foo.com/*', 'http://foo.com/bar/baz/jquery.min.js', { globstar: false }), true); t.equal(match('http://foo.com/**', 'http://foo.com/bar/baz/jquery.min.js', { globstar: true }), true); t.equal(match("http://foo.com/*/*/jquery.min.js", "http://foo.com/bar/baz/jquery.min.js", { globstar: true }), true); t.equal(match("http://foo.com/**/jquery.min.js", "http://foo.com/bar/baz/jquery.min.js", { globstar: true }), true); t.equal(match("http://foo.com/*/*/jquery.min.js", "http://foo.com/bar/baz/jquery.min.js", { globstar: false }), true); t.equal(match("http://foo.com/*/jquery.min.js", "http://foo.com/bar/baz/jquery.min.js", { globstar: false }), true); t.equal(match("http://foo.com/*/jquery.min.js", "http://foo.com/bar/baz/jquery.min.js", { globstar: true }), false); }); test('globrex: extended extglob ?', t => { t.plan(17); t.equal(match('(foo).txt', '(foo).txt', { extended:true }), true); t.equal(match('?(foo).txt', 'foo.txt', { extended:true }), true); t.equal(match('?(foo).txt', '.txt', { extended:true }), true); t.equal(match('?(foo|bar)baz.txt', 'foobaz.txt', { extended:true }), true); t.equal(match('?(ba[zr]|qux)baz.txt', 'bazbaz.txt', { extended:true }), true); t.equal(match('?(ba[zr]|qux)baz.txt', 'barbaz.txt', { extended:true }), true); t.equal(match('?(ba[zr]|qux)baz.txt', 'quxbaz.txt', { extended:true }), true); t.equal(match('?(ba[!zr]|qux)baz.txt', 'batbaz.txt', { extended:true }), true); t.equal(match('?(ba*|qux)baz.txt', 'batbaz.txt', { extended:true }), true); t.equal(match('?(ba*|qux)baz.txt', 'batttbaz.txt', { extended:true }), true); t.equal(match('?(ba*|qux)baz.txt', 'quxbaz.txt', { extended:true }), true); t.equal(match('?(ba?(z|r)|qux)baz.txt', 'bazbaz.txt', { extended:true }), true); t.equal(match('?(ba?(z|?(r))|qux)baz.txt', 'bazbaz.txt', { extended:true }), true); t.equal(match('?(foo).txt', 'foo.txt', { extended:false }), false); t.equal(match('?(foo|bar)baz.txt', 'foobarbaz.txt', { extended:true }), false); t.equal(match('?(ba[zr]|qux)baz.txt', 'bazquxbaz.txt', { extended:true }), false); t.equal(match('?(ba[!zr]|qux)baz.txt', 'bazbaz.txt', { extended:true }), false); }); test('globrex: extended extglob *', t => { t.plan(16); t.equal(match('*(foo).txt', 'foo.txt', { extended:true }), true); t.equal(match('*foo.txt', 'bofoo.txt', { extended:true }), true); t.equal(match('*(foo).txt', 'foofoo.txt', { extended:true }), true); t.equal(match('*(foo).txt', '.txt', { extended:true }), true); t.equal(match('*(fooo).txt', '.txt', { extended:true }), true); t.equal(match('*(fooo).txt', 'foo.txt', { extended:true }), false); t.equal(match('*(foo|bar).txt', 'foobar.txt', { extended:true }), true); t.equal(match('*(foo|bar).txt', 'barbar.txt', { extended:true }), true); t.equal(match('*(foo|bar).txt', 'barfoobar.txt', { extended:true }), true); t.equal(match('*(foo|bar).txt', '.txt', { extended:true }), true); t.equal(match('*(foo|ba[rt]).txt', 'bat.txt', { extended:true }), true); t.equal(match('*(foo|b*[rt]).txt', 'blat.txt', { extended:true }), true); t.equal(match('*(foo|b*[rt]).txt', 'tlat.txt', { extended:true }), false); t.equal(match('*(*).txt', 'whatever.txt', { extended:true, globstar:true }), true); t.equal(match('*(foo|bar)/**/*.txt', 'foo/hello/world/bar.txt', { extended:true, globstar:true }), true); t.equal(match('*(foo|bar)/**/*.txt', 'foo/world/bar.txt', { extended:true, globstar: true }), true); }); test('globrex: extended extglob +', t => { t.plan(4); t.equal(match('+(foo).txt', 'foo.txt', { extended:true }), true); t.equal(match('+foo.txt', '+foo.txt', { extended:true }), true); t.equal(match('+(foo).txt', '.txt', { extended:true }), false); t.equal(match('+(foo|bar).txt', 'foobar.txt', { extended:true }), true); }); test('globrex: extended extglob @', t => { t.plan(6); t.equal(match('@(foo).txt', 'foo.txt', { extended:true }), true); t.equal(match('@foo.txt', '@foo.txt', { extended:true }), true); t.equal(match('@(foo|baz)bar.txt', 'foobar.txt', { extended:true }), true); t.equal(match('@(foo|baz)bar.txt', 'foobazbar.txt', { extended:true }), false); t.equal(match('@(foo|baz)bar.txt', 'foofoobar.txt', { extended:true }), false); t.equal(match('@(foo|baz)bar.txt', 'toofoobar.txt', { extended:true }), false); }); test('globrex: extended extglob !', t => { t.plan(5); t.equal(match('!(boo).txt', 'foo.txt', { extended: true }), true); t.equal(match('!(foo|baz)bar.txt', 'buzbar.txt', { extended: true }), true); t.equal(match('!bar.txt', '!bar.txt', { extended: true }), true); t.equal(match('!({foo,bar})baz.txt', 'notbaz.txt', { extended: true }), true); t.equal(match('!({foo,bar})baz.txt', 'foobaz.txt', { extended: true }), false); }); test('globrex: strict', t => { t.plan(3); t.equal(match('foo//bar.txt', 'foo/bar.txt'), true); t.equal(match('foo///bar.txt', 'foo/bar.txt'), true); t.equal(match('foo///bar.txt', 'foo/bar.txt', { strict:true }), false); }); test('globrex: filepath path-regex', t => { let opts = { extended:true, filepath:true }, res, pattern; res = globrex('', opts); t.is(res.hasOwnProperty('path'), true); t.is(res.path.hasOwnProperty('regex'), true); t.is(res.path.hasOwnProperty('segments'), true); t.is(Array.isArray(res.path.segments), true); pattern = 'foo/bar/baz.js'; res = matchRegex(t, pattern, '/^foo\\/bar\\/baz\\.js$/', '/^foo\\\\+bar\\\\+baz\\.js$/', opts); t.is(res.path.segments.length, 3); res = matchRegex(t, '../foo/bar.js', '/^\\.\\.\\/foo\\/bar\\.js$/', '/^\\.\\.\\\\+foo\\\\+bar\\.js$/', opts); t.is(res.path.segments.length, 3); res = matchRegex(t, '*/bar.js', '/^.*\\/bar\\.js$/', '/^.*\\\\+bar\\.js$/', opts); t.is(res.path.segments.length, 2); opts.globstar = true; res = matchRegex(t, '**/bar.js', '/^((?:[^\\/]*(?:\\/|$))*)bar\\.js$/', '/^((?:[^\\\\]*(?:\\\\|$))*)bar\\.js$/', opts); t.is(res.path.segments.length, 2); t.end(); }) test('globrex: filepath path segments', t => { let opts = { extended:true }, res, win, unix; unix = [/^foo$/, /^bar$/, /^([^\/]*)$/, /^baz\.(md|js|txt)$/]; win = [/^foo$/, /^bar$/, /^([^\\]*)$/, /^baz\.(md|js|txt)$/]; matchSegments(t, 'foo/bar/*/baz.{md,js,txt}', unix, win, {...opts, globstar:true}); unix = [/^foo$/, /^.*$/, /^baz\.md$/]; win = [/^foo$/, /^.*$/, /^baz\.md$/]; matchSegments(t, 'foo/*/baz.md', unix, win, opts); unix = [/^foo$/, /^.*$/, /^baz\.md$/]; win = [/^foo$/, /^.*$/, /^baz\.md$/]; matchSegments(t, 'foo/**/baz.md', unix, win, opts); unix = [/^foo$/, /^((?:[^\/]*(?:\/|$))*)$/, /^baz\.md$/]; win = [/^foo$/, /^((?:[^\\]*(?:\\|$))*)$/, /^baz\.md$/]; matchSegments(t, 'foo/**/baz.md', unix, win, {...opts, globstar:true}); unix = [/^foo$/, /^.*$/, /^.*\.md$/]; win = [/^foo$/, /^.*$/, /^.*\.md$/]; matchSegments(t, 'foo/**/*.md', unix, win, opts); unix = [/^foo$/, /^((?:[^\/]*(?:\/|$))*)$/, /^([^\/]*)\.md$/]; win = [/^foo$/, /^((?:[^\\]*(?:\\|$))*)$/, /^([^\\]*)\.md$/]; matchSegments(t, 'foo/**/*.md', unix, win, {...opts, globstar:true}); unix = [/^foo$/, /^:$/, /^b:az$/]; win = [/^foo$/, /^:$/, /^b:az$/]; matchSegments(t, 'foo/:/b:az', unix, win, opts); unix = [/^foo$/, /^baz\.md$/]; win = [/^foo$/, /^baz\.md$/]; matchSegments(t, 'foo///baz.md', unix, win, {...opts, strict:true}); unix = [/^foo$/, /^baz\.md$/]; win = [/^foo$/, /^baz\.md$/]; matchSegments(t, 'foo///baz.md', unix, win, {...opts, strict:false}); t.end(); }); test('globrex: stress testing', t => { t.plan(8); t.equal(match('**/*/?yfile.{md,js,txt}', 'foo/bar/baz/myfile.md', { extended:true }), true); t.equal(match('**/*/?yfile.{md,js,txt}', 'foo/baz/myfile.md', { extended:true }), true); t.equal(match('**/*/?yfile.{md,js,txt}', 'foo/baz/tyfile.js', { extended:true }), true); t.equal(match('[[:digit:]_.]/file.js', '1/file.js', { extended:true }), true); t.equal(match('[[:digit:]_.]/file.js', '2/file.js', { extended:true }), true); t.equal(match('[[:digit:]_.]/file.js', '_/file.js', { extended:true }), true); t.equal(match('[[:digit:]_.]/file.js', './file.js', { extended:true }), true); t.equal(match('[[:digit:]_.]/file.js', 'z/file.js', { extended:true }), false); });