Skip to content

GI (gitignore matcher) rejects/mis-resolves Windows absolute paths — path-browserify is POSIX-only #1

Description

@sfarnik

Platform: Windows (10.0.28020.2731)
Obsidian Version: 1.13.7
Plugin Version: 2.0.2-beta

Plugin doesn´t even load and crashes immediately:

src/gi.ts imports path-browserify as a mobile-safe substitute for Node's path module . This library only implements POSIX path semantics, so path.isAbsolute() never recognizes Windows-style paths (C:\Users..., UNC \server\share). Since Obsidian Desktop's vault adapter returns a native Windows path for basePath on Windows, this breaks GI.

Suggested fix

Branch on Obsidian's documented Platform.isWin flag (https://docs.obsidian.md/Reference/TypeScript+API/Platform):

eg:

import { Platform } from "obsidian";  
  
function isAbsolutePath(p: string): boolean {  
  return Platform.isWin  
    ? /^[a-zA-Z]:[\\/]/.test(p) || /^\\\\/.test(p)   // Windows: drive-letter or UNC  
    : path.isAbsolute(p);                             // POSIX (path-browserify is fine here)  
}

Similar branching possibly needed elsewhere

gi.ts is not the only place doing path/filesystem logic that could hide platform assumptions. The codebase already has one dedicated module for exactly this class of problem — src/sync2/cross-platform.ts — which centralizes filename-character sanitization, GitHub URL encoding, and rename-portability differences between Capacitor and POSIX cross-platform.ts:1-30 ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions