# url-dirname-normalizer

> Normalize URLs to be valid filesystem paths for archiving web pages and their assets

Latest version **1.4.0** (published 2020-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install url-dirname-normalizer
pnpm add url-dirname-normalizer
yarn add url-dirname-normalizer
bun add url-dirname-normalizer
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2020-12-16 |
| First published | 2020-02-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 94.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Renoir Boulanger |
| Maintainers | renoirb |
| Keywords | url, dirname, path, archiving, normalization |

## Links

- npm: https://www.npmjs.com/package/url-dirname-normalizer
- Repository: https://github.com/renoirb/archivator
- Homepage: https://github.com/renoirb/archivator/blob/v3.x-dev/packages/url-dirname-normalizer
- Issues: https://github.com/renoirb/archivator/issues
- npm.io page: https://npm.io/package/url-dirname-normalizer

## Dependencies (1)

- [esm](https://npm.io/package/esm.md) ^3.2.0

## 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.4.0 (latest) — 2020-12-16
- 1.3.1 — 2020-05-04
- 1.3.0 — 2020-05-04
- 1.2.0 — 2020-02-29
- 1.1.1 — 2020-02-28
- 1.1.0 — 2020-02-28
- 1.0.0 — 2020-02-27

## README

# [url-dirname-normalizer][repo-url]

> Normalize URLs to be valid filesystem paths for archiving web pages and their
> assets

[repo-url]:
  https://github.com/renoirb/archivator/blob/v3.x-dev/packages/url-dirname-normalizer
  'URL Directory Name Normalizer'
[npmjs-package-badge]:
  https://img.shields.io/npm/v/url-dirname-normalizer?style=flat-square&logo=appveyor&label=npm&logo=npm
[npmjs-package]: https://www.npmjs.com/package/url-dirname-normalizer
[bundlesize-badge]:
  https://img.shields.io/bundlephobia/min/url-dirname-normalizer?style=flat-square
[dependabot-badge]:
  https://img.shields.io/librariesio/release/npm/url-dirname-normalizer?style=flat-square&logo=appveyor&logo=dependabot

| Version                                      | Size                                 | Dependencies                                                           |
| -------------------------------------------- | ------------------------------------ | ---------------------------------------------------------------------- |
| [![npm][npmjs-package-badge]][npmjs-package] | ![npm bundle size][bundlesize-badge] | ![Libraries.io dependency status for latest release][dependabot-badge] |

## Usage

### dirnameNormalizer

The default exported function is; `dirnameNormalizer`.

```js
import dirnameNormalizer from 'url-dirname-normalizer'

// HTML Source document URL from where the asset is embedded
// Ignore document origin if resource has full URL, protocol relative, non TLS
const sourceDocument =
  'http://example.org/@ausername/some-lengthy-string-ending-with-a-hash-1a2d8a61510'

/**
 * Filesystem path where to write files to
 */
dirnameNormalizer(sourceDocument)
// > "example.org/ausername/some-lengthy-string-ending-with-a-hash"
```

### normalizer

Alongside the default export, there is also a `normalizer` with a few methods.

Refer to notes in
[**pathName** in `normalizer/path-name.ts`](./src/normalizer/path-name.ts) and
[**searchParams** in `normalizer/search-params.ts`](./src/normalizer/search-params.ts)

```js
import { normalizer } from 'url-dirname-normalizer'
const examplePathName = 'http://www.example.org/fOo/Bar/bAAz.html'
normalizer.pathName(examplePathName)
// > "/foo/bar/baaz"

const exampleSearchParams = 'http://example.org/foo?zulu=please&bar=bazz&buzz'
normalizer.searchParams(exampleSearchParams)
// > "/bar/bazz/zulu/please"
```

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