Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/path.ts>equals

A JavaScript extension package for building strong and modern applications.
Latest
function equals
Re-export
import { equals } from "https://deno.land/x/ayonli_jsext@v0.9.72/path.ts";

Checks if the path1 and path2 describe the same 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

import { equals } from "@ayonli/jsext/path";

console.assert(equals("/usr/bin", "/usr/bin"));
console.assert(equals("C:\\Windows\\System32", "c:/Windows/System32"));
console.assert(equals("http://example.com/foo/bar?foo=bar", "http://example.com/foo/bar"));
console.assert(equals("file://localhost/C:/Windows/System32", "file:///c:/Windows/System32"));

// ignore file protocol
console.assert(equals("file:///C:/Windows/System32", "C:\\Windows\\System32", {
    ignoreFileProtocol: true,
}));

Parameters

path1: string
path2: string
optional
options: PathCompareOptions = [UNSUPPORTED]

Returns

boolean