| Crates.io | link-bridge |
| lib.rs | link-bridge |
| version | 0.2.3 |
| created_at | 2025-07-20 07:38:05.195632+00 |
| updated_at | 2025-08-09 09:53:07.762343+00 |
| description | A lightweight Rust library for creating URL redirects with short names that generate web pages redirecting to longer links on your website. |
| homepage | |
| repository | https://github.com/jerus-org/link-bridge |
| max_upload_size | |
| id | 1760869 |
| size | 55,331 |
A lightweight Rust library for creating URL redirects with short names that generate web pages redirecting to longer links on your website.
This crate provides a simple and efficient way to create HTML redirect pages that automatically forward users from short, memorable paths to longer URLs on your website. Perfect for creating user-friendly shortcuts, maintaining backward compatibility after URL changes, or implementing a simple URL shortening system.
Add this to your Cargo.toml:
[dependencies]
link-bridge = "0.2.3"
use link_bridge::Redirector;
// Create a redirector for a URL path
let mut redirector = Redirector::new("api/v1/users").unwrap();
// Optionally customize the output directory
redirector.set_path("redirects");
// Generate the redirect HTML file
let redirect_path = redirector.write_redirect().unwrap();
This creates an HTML file that automatically redirects visitors from your short URL to the longer target path using multiple redirect methods for maximum compatibility.
The library creates complete HTML5 pages that work across all browsers:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=/your/target/path/">
<script type="text/javascript">
window.location.href = "/your/target/path/";
</script>
<title>Page Redirection</title>
</head>
<body>
If you are not redirected automatically, follow this
<a href='/your/target/path/'>link</a>.
</body>
</html>
The library uses comprehensive error handling:
use link_bridge::{Redirector, RedirectorError};
match Redirector::new("invalid?path") {
Ok(redirector) => println!("Success!"),
Err(RedirectorError::InvalidUrlPath(e)) => {
println!("Invalid path: {}", e);
}
Err(e) => println!("Other error: {}", e),
}
For comprehensive API documentation, examples, and advanced usage patterns, visit:
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
git clone https://github.com/jerus-org/link-bridge.git
cd link-bridge
cargo build
cargo test
# Run all tests
cargo test
# Run with coverage
cargo tarpaulin --out html
See CHANGELOG.md for version history and breaking changes.
This project is licensed under the MIT Licence - see the LICENCE file for details.
For questions, issues, or feature requests, please open an issue on GitHub.