# convert-filepath

> 转换目录

Latest version **1.0.2** (published 2022-04-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install convert-filepath
pnpm add convert-filepath
yarn add convert-filepath
bun add convert-filepath
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-04-19 |
| First published | 2022-04-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | い 狂奔的蜗牛 |
| Maintainers | llf137224350 |
| Keywords | path, convert |

## Links

- npm: https://www.npmjs.com/package/convert-filepath
- Repository: https://github.com/llf137224350/convert-filepath
- Homepage: https://github.com/llf137224350/convert-filepath#readme
- Issues: https://github.com/llf137224350/convert-filepath/issues
- npm.io page: https://npm.io/package/convert-filepath

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2022-04-19
- 1.0.1 — 2022-04-19
- 1.0.0 — 2022-04-19

## README

# 文件路径分隔符转换

> 文件路径分隔符转换，第一个参数为待处理路径，第二个参数为平台，可传入
> * win32 - windows默认路径，a\\\\b\\\\c形式
> * posix - Linux/Unix/Mac OS, a/b/c形式
```javascript

const convertFilepath = require('convert-filepath');
// 带盘符 - 默认分隔符
console.log(convertFilepath('C:\\a\\b\\c\\d')); // C:/a/b/c/d
console.log(convertFilepath('C:\\a\\b\\c\\..\\d')); // C:/a/b/d
console.log(convertFilepath('C:\\a\\b\\c\\..\\..\\d')); // C:/a/d
console.log(convertFilepath('C:\\a\\b\\c\\..\\..\\..\\d')); // C:/d
// 不带盘符 - 默认分隔符
console.log(convertFilepath('\\a\\b\\c\\d')); // /a/b/c/d
console.log(convertFilepath('\\a\\b\\c\\..\\d')); // /a/b/d
console.log(convertFilepath('\\a\\b\\c\\..\\..\\d')); // /a/d
console.log(convertFilepath('\\a\\b\\c\\..\\..\\..\\d')); // /d

// 带盘符 - 自定义\\分隔符
console.log(convertFilepath('C:\\a\\b\\c\\d', 'win32')); // C:\\a\\b\\c\\d
console.log(convertFilepath('C:\\a\\b\\c\\..\\d', 'win32')); // C:\\a\\b\\d
console.log(convertFilepath('C:\\a\\b\\c\\..\\..\\d', 'win32')); // C:\\a\\d
console.log(convertFilepath('C:\\a\\b\\c\\..\\..\\..\\d', 'win32')); // C:\\d
// 不带盘符 - 自定义\\分隔符
console.log(convertFilepath('\\a\\b\\c\\d', 'win32')); // \\a\\b\\c\\d
console.log(convertFilepath('\\a\\b\\c\\..\\d', 'win32')); // \\a\\b\\d
console.log(convertFilepath('\\a\\b\\c\\..\\..\\d', 'win32')); // \\a\\d
console.log(convertFilepath('\\a\\b\\c\\..\\..\\..\\d', 'win32')); // \\d

```

---
_Source: https://npm.io/package/convert-filepath · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
