JSPM

@danielhaim/analyzeredirects

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q27899F
  • License MIT

A tool to analyze and resolve conflicting URL redirects.

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@danielhaim/analyzeredirects) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Analyze Redirects

    npm version Downloads GitHub

    Demo Image

    Overview

    AnalyzeRedirects is a tool for analyzing URL redirects, identifying duplicates and conflicts, and generating .htaccess or .nginx style redirect rules.

    Installation

    Install AnalyzeRedirects using NPM:

    npm i @danielhaim/analyzeredirects
    1. Link the Package Locally If you're working on the project locally and want to test your changes in your environment, use npm link:
    npm link
    1. Linking in another project If you want to link this package into another project for testing or development, you can use this command inside the target project:
    npm link @danielhaim/analyzeredirects

    API Documentation

    Once installed, you can use the command-line interface (CLI) to analyze your redirects and generate .txt files with the rules. Here's how to use it:

    # If you have linked the package locally:
    analyze-redirects --file <path_to_your_json_file> [options]
    
    # If you installed the package normally:
    npx analyze-redirects --file <path_to_your_json_file> [options]

    Options:

    • -f, --file <path>: Path to JSON file with Old_URL and New_URL.
    • -o, --output <path>: Path to output the generated redirects file (default: ./dist/redirects.txt).
    • -a, --analyze-only: Only analyze redirects without generating output file.
    • -s, --silent: Suppress console output.
    • -h, --help: Display this help message.

    Examples:

    To analyze redirects and see the output in the console:

    analyze-redirects --file ./__test__/demo-urls.json

    To generate a file with the redirects:

    analyze-redirects -f ./__test__/demo-urls.json -o ./output-redirects.txt

    To analyze without generating a file:

    analyze-redirects --file ./__test__/demo-urls.json --analyze-only

    Adding a New URL Set

    To add a new set of redirects, create a urls.json file in the ./sets/ directory with the following structure:

    [
        { "Old_URL": "/old-page", "New_URL": "https://example.com/new-page" },
        { "Old_URL": "/another-page", "New_URL": "https://example.com/another-page" }
    ]

    Once your set is added, you can analyze it using the CLI by specifying the path to your urls.json file.

    License

    This software is released under the MIT License

    Report Issues or Request a Feature

    If you encounter any issues or have suggestions for improvements, please feel free to report them. Your feedback is invaluable in enhancing this software.

    Folder Structure

    Here's an overview of the project's folder structure:

    .
    ├── LICENSE
    ├── README.md
    ├── __test__
    │   ├── analyzeredirects.test.js
    │   ├── demo-redirects.txt
    │   ├── demo-urls.json
    │   └── expected-demo-redirects.txt
    ├── babel.config.js
    ├── cli.js
    ├── index.js
    ├── jest.config.mjs
    ├── package-lock.json
    ├── package.json
    ├── sets
    │   └── urls.json
    └── src
        ├── index.js
        └── util.analyze.js
    • __test__: Contains test files and sample data.
    • cli.js: The CLI entry point.
    • sets/urls.json: Default set for analysis, you can add your own sets here.
    • src/: Source code for redirect analysis and utilities.