1.4.0 • Published 3 years ago

url-dirname-normalizer v1.4.0

Weekly downloads
12
License
MIT
Repository
github
Last release
3 years ago

url-dirname-normalizer

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

VersionSizeDependencies
npmnpm bundle sizeLibraries.io dependency status for latest release

Usage

dirnameNormalizer

The default exported function is; dirnameNormalizer.

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 and searchParams in normalizer/search-params.ts

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"
1.4.0

3 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago