# parse-filename

> Parse a File Name from a Given URL or Data Path

Latest version **0.0.0** (published 2021-03-23) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install parse-filename
pnpm add parse-filename
yarn add parse-filename
bun add parse-filename
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.0 |
| Published | 2021-03-23 |
| First published | 2021-03-23 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Daniel J. Dufour |
| Maintainers | danieljdufour |
| Keywords | extension, filename, url |

## Links

- npm: https://www.npmjs.com/package/parse-filename
- Repository: https://github.com/DanielJDufour/parse-filename
- Homepage: https://github.com/DanielJDufour/parse-filename#readme
- Issues: https://github.com/DanielJDufour/parse-filename/issues
- npm.io page: https://npm.io/package/parse-filename

## 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

- 0.0.0 (latest) — 2021-03-23

## README

# parse-filename
> Parse a File Name from a Given URL or Data Path

# features
- zero dependencies
- cross-platform
- ignores URL parameters

# supported input
- http and https urls, like `https://example.org/folder/file.txt`
- ssh urls, like `ubuntu@example.org:/tmp/test.txt`
- git urls, like `git@github.com:DanielJDufour/parse-filename/README.md`
- unix filepaths, like `/tmp/file.txt`
- windows filepaths, like `C:\WINDOWS\explorer.exe`
- s3 urls, like `s3://bucket/file.txt`

# install
```bash
npm install parse-filename
```

# usage
## importing/loading
```javascript
import parseFileName from 'parse-filename'
```
or
```javascript
const parseFileName = require('parse-filename');
```
or
```html
<script src="https://unpkg.com/parse-filename">
```

## parsing
```javascript
const result = parseFileName({
  data: "https://github.com/DanielJDufour/parse-filename/blob/main/README.md",
  debug: false // set to true for increased logging
});
// result is { extension: "md", filename: "README.md" }
```

## advanced usage
You can specify three additional arguments
```javascript
const result = parseFileName({
  data: "https://example.org/testpath/f.zip",
  max_extension_length = 10,
  min_extension_length = 1,
  min_filename_length = 3
});
// returns { extension: null, filename: null } because filename is too short
```

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