{"id":13484805,"url":"https://github.com/rhysd/fixred","last_synced_at":"2025-04-15T17:32:07.309Z","repository":{"id":38319464,"uuid":"409671584","full_name":"rhysd/fixred","owner":"rhysd","description":"Fix outdated links in files with redirect URLs","archived":false,"fork":false,"pushed_at":"2022-06-07T04:10:37.000Z","size":68,"stargazers_count":36,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T20:50:59.702Z","etag":null,"topics":["command-line-tool","fixer","outdated-urls"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rhysd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-23T16:45:53.000Z","updated_at":"2025-02-06T14:24:45.000Z","dependencies_parsed_at":"2022-08-17T15:55:58.156Z","dependency_job_id":null,"html_url":"https://github.com/rhysd/fixred","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Ffixred","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Ffixred/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Ffixred/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Ffixred/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhysd","download_url":"https://codeload.github.com/rhysd/fixred/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249118779,"owners_count":21215618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line-tool","fixer","outdated-urls"],"created_at":"2024-07-31T17:01:34.178Z","updated_at":"2025-04-15T17:32:07.055Z","avatar_url":"https://github.com/rhysd.png","language":"Rust","funding_links":[],"categories":["Rust","Tool Collection"],"sub_categories":["Search"],"readme":"fixred\n======\n[![crate][crates-io-badge]][crates-io]\n[![CI][ci-badge]][ci]\n\n[fixred][repo] is a command line utility to fix outdated links in files with redirect URLs.\n\n\u003cimg src=\"https://github.com/rhysd/ss/raw/master/fixred/main.gif\" alt=\"demo\" width=\"590\" height=\"396\" /\u003e\n\n## Installation\n\nfixred is installed via [cargo][] package manager. [libcurl][] is necessary as dependency.\n\n```sh\ncargo install fixred\nfixred --help\n```\n\nIf you don't have Rust toolchain, [a Docker image][docker] is also available.\n\n```sh\ndocker run -it --rm rhysd/fixred:latest --help\n```\n\n## Usage\n\nfixred checks redirects of URLs in text files. When a URL is redirected, fixred replaces it with the redirected one.\nfixred ignores invalid URLs or broken links (e.g. 404) to avoid false positives in extracted URLs.\n\nSee the help output for each flags, options, and arguments.\n\n```sh\nfixred --help\n```\n\n### Fix files\n\nMost basic usage is fixing files by passing them to command line arguments.\n\n```sh\n# Fix a file\nfixred ./docs/usage.md\n\n# Fix all files in a directory (recursively)\nfixred ./docs\n\n# Multiple paths can be passed\nfixred ./README.md ./CONTRIBUTING.md ./docs\n```\n\nNote that fixred only handles UTF8 files. Non-UTF8 files are ignored. To know which files were ignored, try `--verbose`\nflag.\n\n### Fix stdin\n\nWhen no argument is given, fixred reads stdin and outputs result to stdout.\n\n```sh\ncat ./docs/usage.md | fixred\n```\n\n### Run via Docker container\n\nMount local directories with `-v` and pass an environment variable (if necessary) with `-e`. Running\n[the Docker image][docker] executes `fixred` executable by default.\n\n```sh\n# Fix all files in ./docs\ndocker run -it --rm -v $(pwd):/app -e FIXRED_LOG=info rhysd/fixred:latest /app/docs\n```\n\nPassing the input via stdin is also possible. The result is output to stdout.\n\n```sh\n# Fix stdin and output the result to stdout\ncat ./docs/usage.md | docker run -i --rm rhysd/fixred:latest\n```\n\n### Redirect only once\n\nBy default, fixred follows redirects repeatedly and uses the last URL to replace. However, sometimes redirecting only\nonce would be more useful. `--shallow` flag is available for it.\n\nFor example, link to raw README file in `rhysd/vim-crystal` repository (moved to `vim-crystal/vim-crystal` later) is\nredirected as follows.\n\n1. https://github.com/rhysd/vim-crystal/raw/master/README.md\n2. https://github.com/vim-crystal/vim-crystal/raw/master/README.md\n3. https://raw.githubusercontent.com/vim-crystal/vim-crystal/master/README.md\n\nWhen you want to fix 1. to 2. but don't want to fix 1. to 3., `--shallow` is useful.\n\n```sh\nfixred --shallow ./README.md\n```\n\n### Filtering URLs\n\nWhen you want to fix only specific links in a file, filtering URLs with regular expressions is available. The following\nexample fixes URLs which starts with `https://github.com/` using `--extract` option.\n\n```sh\nfixred --extract '^https://github\\.com/' ./docs\n```\n\n`--ignore` option is an invert version of `--extract`. URLs matched to the pattern are ignored. The following example\navoids to resolve URLs which contain hashes.\n\n```sh\nfixred --ignore '#' ./docs\n```\n\n### Verbose logs\n\nBy default, fixred outputs nothing when it runs successfully. For verbose log outputs, `--verbose` flag or `$FIXRED_LOG`i\nenvironment variable is available.\n\n```sh\n# Outputs which file is being processed\nfixred --verbose\n# Or\nFIXRED_LOG=info fixred ./docs\n\n# Outputs what fixred is doing in detail\nFIXRED_LOG=debug fixred ./docs\n```\n\n### Real-world examples\n\n- Followed the large update of GitHub document links\n  - https://github.com/rhysd/actionlint/commit/0b7375279d2caf63203701eccc39ab091cc83a50\n  - https://github.com/rhysd/actionlint/commit/a3f270b313affa81cc41709587cbd2588d4ac4ce\n- Followed the repository transition\n  - https://github.com/benchmark-action/github-action-benchmark/commit/450cb083343edcf0fb6d82a917f890eaf2cd073f\n\n## Use this tool as Rust library\n\nPlease see [the API document][api]. And for the real world example, please see [src](./src) directory.\n\nTo install as dependency, add `fixred` to your `Cargo.toml` file. Ensure to disable default features.\nIt removes all unnecessary dependencies for using this tool as library.\n\n```toml\n[dependencies]\nfixred = { version = \"1\", default-features = false, features = [] }\n```\n\nHere is a small example code\n\n```rust\nuse fixred::resolve::CurlResolver;\nuse fixred::redirect::Redirector;\n\nfn main() {\n    let red = Redirector::\u003cCurlResolver\u003e::default();\n    let fixed = red.fix(std::io::stdin(), std::io::stdout()).unwrap();\n    eprintln!(\"Fixed {} link(s)\", fixed);\n}\n```\n\n## License\n\nDistributed under [the MIT license](./LICENSE.txt).\n\n[repo]: https://github.com/rhysd/fixred\n[cargo]: https://doc.rust-lang.org/cargo/\n[libcurl]: https://curl.se/libcurl/\n[ci]: https://github.com/rhysd/fixred/actions/workflows/ci.yaml\n[ci-badge]: https://github.com/rhysd/fixred/actions/workflows/ci.yaml/badge.svg\n[crates-io]: https://crates.io/crates/fixred\n[crates-io-badge]: https://img.shields.io/crates/v/fixred.svg\n[docker]: https://hub.docker.com/r/rhysd/fixred\n[api]: https://docs.rs/fixred\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhysd%2Ffixred","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhysd%2Ffixred","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhysd%2Ffixred/lists"}