Skip to content

[Replacement]: path-root #1016

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

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

    acceptedUsed to signal if a suggested replacement has been accepted.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions