Skip to content

[Replacement]: path-root #1016

Closed
Closed

Description

@outslept

Package to replace

path-root (+path-root-regex)

Suggested replacement(s)

for node

import { parse} from 'node:path';
parse(filepath).root; 

for browser leave

const ROOT_RE = /^(?:[a-zA-Z]:|[\\/]{2}[^\\/]+[\\/]+[^\\/]+)?[\\/]?;

export default (filepath) => {
  if (typeof filepath !== 'string') throw new TypeError('expected a string');
  return ROOT_RE.exec(filepath)[0];
};

Manifest type

micro-utility (tiny utility replaceable with native code or removal)

Rationale

inlinable

Availability

No response

Code example (optional)

Activity

  1. outslept commented on Aug 26, 2026

    @outslept
    ContributorAuthor

    IDK where to put this.. maybe native is more suitable

  2. 43081j commented on Aug 26, 2026

    @43081j
    Contributor

    maybe we can put it in micro-utilities but give it a doc to explain the two usages (node vs browser)

  3. added
    accepted
    on Aug 26, 2026
  4. gameroman commented on Aug 26, 2026

    @gameroman
    Contributor

    Most downloads come from parse-filepath

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

    accepted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions