2024-01-10 21:05:28 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-06-03 13:54:18 +00:00
|
|
|
import { assertEquals, assertThrows } from "@std/assert";
|
2024-01-10 21:05:28 +00:00
|
|
|
import { normalizeGlob } from "./normalize_glob.ts";
|
2024-06-03 13:54:18 +00:00
|
|
|
import * as posix from "./posix/mod.ts";
|
|
|
|
import * as windows from "./windows/mod.ts";
|
2024-01-18 05:54:39 +00:00
|
|
|
import { SEPARATOR } from "./constants.ts";
|
2024-01-10 21:05:28 +00:00
|
|
|
|
|
|
|
Deno.test("normalizeGlob() checks options.globstar", function () {
|
2024-01-18 05:54:39 +00:00
|
|
|
assertEquals(
|
|
|
|
normalizeGlob(`**${SEPARATOR}..`, { globstar: true }),
|
|
|
|
`**${SEPARATOR}..`,
|
|
|
|
);
|
2024-01-10 21:05:28 +00:00
|
|
|
});
|
2024-06-03 13:54:18 +00:00
|
|
|
|
|
|
|
Deno.test("normalizeGlob() throws if it contains \\0 character", () => {
|
|
|
|
assertThrows(
|
|
|
|
() => {
|
|
|
|
posix.normalizeGlob("\0");
|
|
|
|
},
|
|
|
|
Error,
|
|
|
|
"Glob contains invalid characters:",
|
|
|
|
);
|
|
|
|
assertThrows(
|
|
|
|
() => {
|
|
|
|
windows.normalizeGlob("\0");
|
|
|
|
},
|
|
|
|
Error,
|
|
|
|
"Glob contains invalid characters:",
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
Deno.test(
|
|
|
|
"normalizeGlob() works as the same way as normalize if globstar option is false",
|
|
|
|
() => {
|
|
|
|
assertEquals(
|
|
|
|
posix.normalizeGlob("foo/bar/../baz"),
|
|
|
|
"foo/baz",
|
|
|
|
);
|
|
|
|
assertEquals(windows.normalizeGlob("foo/bar/../baz"), "foo\\baz");
|
|
|
|
},
|
|
|
|
);
|