deno.land / std@0.224.0 / path / is_absolute_test.ts

is_absolute_test.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// Copyright the Browserify authors. MIT License.// Ported from https://github.com/browserify/path-browserify/import { assertEquals } from "../assert/mod.ts";import * as posix from "./posix/mod.ts";import * as windows from "./windows/mod.ts";import { isAbsolute } from "./is_absolute.ts";
Deno.test("posix.isAbsolute()", function () { assertEquals(posix.isAbsolute("/home/foo"), true); assertEquals(posix.isAbsolute("/home/foo/.."), true); assertEquals(posix.isAbsolute("bar/"), false); assertEquals(posix.isAbsolute("./baz"), false);});
Deno.test("windows.isAbsolute()", function () { assertEquals(windows.isAbsolute("/"), true); assertEquals(windows.isAbsolute("//"), true); assertEquals(windows.isAbsolute("//server"), true); assertEquals(windows.isAbsolute("//server/file"), true); assertEquals(windows.isAbsolute("\\\\server\\file"), true); assertEquals(windows.isAbsolute("\\\\server"), true); assertEquals(windows.isAbsolute("\\\\"), true); assertEquals(windows.isAbsolute("c"), false); assertEquals(windows.isAbsolute("c:"), false); assertEquals(windows.isAbsolute("c:\\"), true); assertEquals(windows.isAbsolute("c:/"), true); assertEquals(windows.isAbsolute("c://"), true); assertEquals(windows.isAbsolute("C:/Users/"), true); assertEquals(windows.isAbsolute("C:\\Users\\"), true); assertEquals(windows.isAbsolute("C:cwd/another"), false); assertEquals(windows.isAbsolute("C:cwd\\another"), false); assertEquals(windows.isAbsolute("directory/directory"), false); assertEquals(windows.isAbsolute("directory\\directory"), false);});
Deno.test("isAbsolute() returns false if input is empty", function () { assertEquals(isAbsolute(""), false);});
std

Version Info

Tagged at
6 months ago