https://github.com/danielhaim1/analyzeredirects
A tool to analyze and resolve conflicting URL redirects.
https://github.com/danielhaim1/analyzeredirects
Last synced: 4 months ago
JSON representation
A tool to analyze and resolve conflicting URL redirects.
- Host: GitHub
- URL: https://github.com/danielhaim1/analyzeredirects
- Owner: danielhaim1
- License: mit
- Created: 2024-12-01T17:43:48.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-15T22:52:25.000Z (over 1 year ago)
- Last Synced: 2025-11-02T03:22:20.079Z (7 months ago)
- Language: JavaScript
- Size: 507 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Analyze Redirects
==========
[](https://www.npmjs.com/package/@danielhaim/analyzeredirects)
[](https://www.npmjs.com/package/@danielhaim/analyzeredirects)


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:
```shell
npm i @danielhaim/analyzeredirects
```
2. Link the Package Locally
If you're working on the project locally and want to test your changes in your environment, use `npm link`:
```shell
npm link
```
3. 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:
```shell
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:
```bash
# If you have linked the package locally:
analyze-redirects --file [options]
# If you installed the package normally:
npx analyze-redirects --file [options]
```
### Options:
- `-f`, `--file `: Path to JSON file with Old_URL and New_URL.
- `-o`, `--output `: 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:
```bash
analyze-redirects --file ./__test__/demo-urls.json
```
To generate a file with the redirects:
```bash
analyze-redirects -f ./__test__/demo-urls.json -o ./output-redirects.txt
```
To analyze without generating a file:
```bash
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:
```json
[
{ "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](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:
```bash
.
├── 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.