close
Skip to content

warengonzaga/expandurl-cli

ExpandURL CLI

npm version license pnpm

🔗 A powerful command-line tool to expand shortened URLs to their final destination, with built-in Cloudflare bypass support.

✨ Features

  • 🚀 Fast & Efficient - Uses native Node.js HTTP modules for lightning-fast URL expansion
  • 🛡️ Cloudflare Bypass - Automatically handles Cloudflare-protected shorteners (shorturl.at, etc.)
  • 🔄 Multiple URLs - Expand multiple shortened URLs in one command
  • 📊 Verbose Mode - View detailed information including status codes and redirect counts
  • 🎨 Beautiful Output - Color-coded, easy-to-read terminal output
  • Zero Dependencies - Core functionality uses only native Node.js modules
  • 🔧 Configurable - Customize timeout and redirect limits

📦 Installation

Global Installation (Recommended)

Using pnpm:

pnpm add -g expandurl-cli

Using npm:

npm install -g expandurl-cli

Using yarn:

yarn global add expandurl-cli

For Cloudflare-Protected URLs

To enable browser fallback for Cloudflare-protected shorteners:

pnpm add -g expandurl-cli
npx playwright install chromium

🚀 Usage

Basic Usage

Expand a single shortened URL:

expandurl https://bit.ly/example

Multiple URLs

Expand multiple URLs at once:

expandurl https://bit.ly/example https://tinyurl.com/example https://shorturl.at/abc123

Verbose Mode

Get detailed information with status codes and redirect counts:

expandurl --verbose https://bit.ly/example

Or use the shorthand:

expandurl -v https://bit.ly/example

Custom Configuration

Set custom timeout (in milliseconds):

expandurl --timeout 5000 https://bit.ly/example

Set maximum redirect limit:

expandurl --max-redirects 5 https://bit.ly/example

Combine options:

expandurl -v -t 15000 -m 20 https://bit.ly/example

🎯 Options

Option Alias Description Default
--timeout <ms> -t Request timeout in milliseconds 10000
--max-redirects <count> -m Maximum redirects to follow 10
--verbose -v Show status code and redirect count false
--sponsor -s Show sponsor information -
--version -V Show version number -
--help -h Show help information -

🔍 How It Works

  1. Native HTTP/HTTPS - Primary method using Node.js built-in modules for fast URL expansion
  2. Redirect Following - Automatically follows HTTP redirects (301, 302, 307, 308)
  3. Cloudflare Detection - Detects 403 responses from Cloudflare-protected URLs
  4. Browser Fallback - Automatically switches to headless browser for Cloudflare bypass when needed
  5. Error Handling - Graceful error handling with helpful error messages

🛠️ Supported URL Shorteners

Works with most URL shorteners including:

  • ✅ bit.ly
  • ✅ tinyurl.com
  • ✅ shorturl.at (Cloudflare-protected)
  • ✅ t.co
  • ✅ ow.ly
  • ✅ is.gd
  • ✅ buff.ly
  • ✅ And many more!

📝 Examples

Example 1: Basic URL expansion

$ expandurl https://bit.ly/3xample
https://bit.ly/3xample → https://github.com/warengonzaga/expandurl-cli

Example 2: Verbose mode with details

$ expandurl -v https://bit.ly/3xample
https://bit.ly/3xample → https://github.com/warengonzaga/expandurl-cli (status: 200, redirects: 1)

Example 3: Multiple URLs

$ expandurl https://bit.ly/example1 https://tinyurl.com/example2
https://bit.ly/example1 → https://github.com/user/repo1
https://tinyurl.com/example2 → https://example.com/page

Example 4: Cloudflare-protected URL

$ expandurl https://shorturl.at/abc123
https://shorturl.at/abc123 → https://destination-url.com

🤝 Contributing

Contributions are welcome! Please read our Contributing Guidelines before submitting a pull request.

Development Workflow

  1. Fork the repository
  2. Create a feature branch from dev: git checkout -b feature/your-feature dev
  3. Make your changes
  4. Test your changes: node bin/expandurl.js <test-url>
  5. Commit using Clean Commit convention
  6. Push to your fork and submit a pull request to the dev branch

📄 License

This project is licensed under the ISC License - see the LICENSE file for details.

👨‍💻 Author

Waren Gonzaga

💜 Sponsor

Love this project? Consider sponsoring me on GitHub to support continued development!

Sponsor

🙏 Acknowledgments

  • Built with native Node.js modules for maximum performance
  • Commander.js for CLI framework
  • Chalk for beautiful terminal output
  • Figlet for ASCII art
  • Playwright for Cloudflare bypass capability

Made with ❤️ by Waren Gonzaga

About

A powerful command-line tool to expand shortened URLs to their final destination, with built-in Cloudflare bypass support.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors