diff options
author | Nayeem Rahman <muhammed.9939@gmail.com> | 2020-02-06 22:25:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-06 17:25:39 -0500 |
commit | 971391dbaf8f5273eb2f16edd22b0c6cf694be46 (patch) | |
tree | 901a658522b9080221bb931c1504361c90ec8d18 /std/path/globrex_test.ts | |
parent | 699d10bd9e5f19ad2f4ffb82225c86690a092c07 (diff) |
fix(std/path/globrex.ts): Use non-capturing groups in globrex() (#3898)
Diffstat (limited to 'std/path/globrex_test.ts')
-rw-r--r-- | std/path/globrex_test.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/std/path/globrex_test.ts b/std/path/globrex_test.ts index 31607216d..f091ebe9b 100644 --- a/std/path/globrex_test.ts +++ b/std/path/globrex_test.ts @@ -4,7 +4,7 @@ import { test } from "../testing/mod.ts"; import { assertEquals } from "../testing/asserts.ts"; -import { globrex } from "./globrex.ts"; +import { GlobrexOptions, globrex } from "./globrex.ts"; const isWin = Deno.build.os === "win"; const t = { equal: assertEquals, is: assertEquals }; @@ -13,14 +13,18 @@ function match( glob: string, strUnix: string, strWin?: string | object, - opts = {} + opts: GlobrexOptions = {} ): boolean { if (typeof strWin === "object") { opts = strWin; strWin = ""; } - const res = globrex(glob, opts); - return res.regex.test(isWin && strWin ? strWin : strUnix); + const { regex } = globrex(glob, opts); + const match = (isWin && strWin ? strWin : strUnix).match(regex); + if (match && !regex.flags.includes("g")) { + assertEquals(match.length, 1); + } + return !!match; } test({ |