summaryrefslogtreecommitdiff
path: root/plugins/claude-security/scripts/lib/absolute.py
blob: 45f28ed3ef80cb0e5c8cab96c0deebc7afe1855f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""Whether a path is spelled absolutely on any platform, not just the one this runs on."""

from __future__ import annotations

import ntpath
import os


def spelled(path: str) -> bool:
    """True for a rooted, drive-qualified or UNC path, whichever platform reads it."""
    return (
        os.path.isabs(path)
        or path.replace("\\", "/").startswith("/")
        or bool(ntpath.splitdrive(path)[0])
    )