import { contains } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/path/util.js";
Checks if the path
contains the given sub
path.
This function doesn't check the path string directly, instead, it checks the path segments.
This function is ignorant about the path separator, the query string and the hash string (if present). And is case-insensitive on Windows volume symbol by default.
Examples
Example 1
Example 1
import { contains } from "@ayonli/jsext/path";
console.assert(contains("/usr/bin", "/usr"));
console.assert(contains("C:\\Windows\\System32", "Windows\\System32"));
console.assert(contains("http://example.com/foo/bar", "foo"));
console.assert(contains("file:///C:/Windows/System32", "C:/Windows/System32"));
// To be noted, the origin portion of a URL is considered as a whole segment.
console.assert(!contains("http://example.com/foo/bar", "example.com"));
console.assert(contains("http://example.com/foo/b", "http://example.com"));