Skip to content

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

License

Notifications You must be signed in to change notification settings

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 2

  •  
  •