url-sanitizer
is a Rust command-line tool designed to process and sanitize URLs, removing unwanted parameters or formatting them for safe use. This tool is lightweight, fast, and built for reliability.
- Sanitizes URLs (e.g., removes tracking parameters or normalizes formats).
- Fast execution with Rust's performance.
- Portable, statically linked binary for easy distribution.
To build and install url-sanitizer
on a Debian system, ensure the following are installed:
- Rust and Cargo: The Rust toolchain.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env
- musl-tools: For static linking with the
musl
target.sudo apt update sudo apt install musl-tools
- Git: To clone the repository (optional if you have the local codebase).
sudo apt install git
Verify installations:
rustc --version && cargo --version && git --version
Follow these steps to build a statically linked binary, which can run on any x86_64 Linux system without external library dependencies.
- Clone the repository:
# http git clone
git clone https://github.com/LinuxUser255/url-sanitizer.git
cd url-sanitizer
- Add the
musl
Target:rustup target add x86_64-unknown-linux-musl
- Build the Static Binary:
Compile in release mode for an optimized, standalone binary:
The binary will be at
cargo build --release --target x86_64-unknown-linux-musl
target/x86_64-unknown-linux-musl/release/url-sanitizer
.
- Verify Static Linking:
Ensure the binary has no dynamic dependencies:
Expected output:
ldd target/x86_64-unknown-linux-musl/release/url-sanitizer
statically linked
ornot a dynamic executable
.
- Optional: Strip the Binary:
Reduce binary size by removing debug symbols:
strip target/x86_64-unknown-linux-musl/release/url-sanitizer
- Install Globally:
Move the binary to
/usr/local/bin
for system-wide access:Verify it’s accessible:sudo mv target/x86_64-unknown-linux-musl/release/url-sanitizer /usr/local/bin/
which url-sanitizer
- Test the Binary:
Run the tool to ensure it works:
(Replace
url-sanitizer --help
--help
with appropriate arguments if your CLI requires them.)
➜ ~ url-sanitizer -h
Usage: url-sanitizer --url <URL>
Options:
-u, --url <URL>
-h, --help Print help
-V, --version Print version
url-sanitizer --url https://youtu.be/gW464nWLdAs\?si\=TAZ3qCA1503uB__t
Sanitized URL: https://youtu.be/gW464nWLdAs